I have a question about asynchrony in Javascript. From what I was able to read, is that Javascript uses only one thread, but is capable of handling events asynchronously.
I have the following code:
game.next(); this.autopilot();
Now I need to execute the game.next function before the this.autopilot function is this.autopilot . Is Javascript really waiting for game.next complete or is this.autopilot istantly executing it?
If so, is the callback performing the problem?
The following callback function:
Game.prototype.next = function(callback) {
The calling function using this callback:
game.next(function() { this.autopilot(); }.bind(this));
source share