Skip to content

Instantly share code, notes, and snippets.

@gustavo-rodrigues-dev
Last active March 16, 2017 20:30
Show Gist options
  • Save gustavo-rodrigues-dev/4dba3894ec2a1f51e54bfaf444c6ced3 to your computer and use it in GitHub Desktop.
Save gustavo-rodrigues-dev/4dba3894ec2a1f51e54bfaf444c6ced3 to your computer and use it in GitHub Desktop.
exemple fail
function add(name){
setTimeout(function(){
names.push(name);
}, 100);
return name;
}
console.log(names); // []
console.log(add('Gustavo')); // Gustavo
console.log(names); // []
//when exists data
setTimeout(function(){
console.log(names) // ['Gustavo']
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment