javascriptfunction

Strange JavaScript behaviour?


I have a simple function that calls other functions:

function update() {
    updateMissiles();
    updatePlayer;
    updateTurbines();

}

They are similar to each other in every way except updatePlayer will not run if I put brackets on the end of it. This doesn't break any code but I'm still curious why it does that?


Solution

  • I'm guessing there's an Exception in the updatePlayer method and since you're not calling it in the code you pasted above, you're not getting the Exception.

    I would open up the Developer Tools for whatever browser you're using and see if there are any JavaScript Exceptions being thrown.