Created
September 3, 2019 19:36
-
-
Save camilomontoyau/e2bb6180936a1894aca9dcf1c399297c to your computer and use it in GitHub Desktop.
scope.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* for (var i = 1; i <= 5; i++) { | |
(function() { | |
setTimeout(function timer() { | |
console.log(i); | |
}, i * 1000); | |
})(); | |
} */ | |
/* for (var i = 1; i <= 5; i++) { | |
(function() { | |
var j = i; | |
setTimeout(function timer() { | |
console.log(j); | |
}, i * 1000); | |
})(); | |
} */ | |
for (let i = 1; i <= 5; i++) { | |
(function() { | |
setTimeout(function timer() { | |
console.log(i); | |
}, i * 1000); | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment