Created
June 4, 2021 20:27
-
-
Save bhushan/d66036ad649dba0e965529ac3f6992f0 to your computer and use it in GitHub Desktop.
Most asked Amazon and Google Question on setTimeout
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
const arr = [1, 2, 3, 4]; | |
for (var i = 0; i < arr.length; i++) { | |
setTimeout(function() { | |
console.log('Index: ' + i + ', Element: ' + arr[i]); | |
}, 3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment