Skip to content

Instantly share code, notes, and snippets.

@JBarna
Created April 10, 2017 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JBarna/0648834ea106dff072cf0bc14ffc6bd9 to your computer and use it in GitHub Desktop.
Save JBarna/0648834ea106dff072cf0bc14ffc6bd9 to your computer and use it in GitHub Desktop.
Example of JavaScript asyncronous nature
for (var i = 0; i < 10; i++ ){
setTimeout( function() {
console.log( "value is " + i);
}, 1000);
}
// what will the output be?
// go to https://goo.gl/lFkgcr to run the code
// setTimeout will call the first argument, a function, at the specified milliseconds.
// it's asyncronous, so the code around it is going to keep running in the meantime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment