Jump to Categories


Also know as async, asynchronous is the opposite of synchronous. It doesn't wait for each operation to complete, instead it executes everything and then handles the operations once their results are available. By nature javascript is synchronous so you have to make use of API's - such as timeouts, Ajax, requestAnimationFrame etc - to perform async tasks.

window.setTimeout(function() {
}, 1000);

// one
// three
// two

In this example - from Bergi on Stack Overflow - the operations run one after another, but when the browser encounters the setTimeout it fires it, but carries on executing the rest of the code until it has returned a result and is ready to be console.logged.