Forums

OverviewV-Play 1 Support › JS shorthand operator

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6324

    Michael

    Hi

    I think shorthand addition operator (+=) is not working in external Javascript, e.g.

    function test() {
        var total
        for (var i=0; i<100; i++){
            total += i
        }
        console.log("1: total = " + total)  // produces "1: total = NaN"
    
        total = 0
    
        for (var i=0; i<100; i++){
            total = total + i
        }
        console.log("2: total = " + total)  // produces 2: "total = 4950"
    
    }

    I think this is strange – this kind of operator is ok in QML JS, but not for external JS.

    Cheers, Michael.

    #6326

    Christian
    V-Play Team

    Hi Michale,

    please try to initialize the total var with 0 (to indicate it’s a number), then the += should work as expected.

    Cheers, Chris

    #6327

    Michael

    oops – sorry about that. That makes sense.

    Cheers, Michael.

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support