Skip to content

Instantly share code, notes, and snippets.

@jtomchak
Created July 24, 2017 18:18
Show Gist options
  • Save jtomchak/c251b2a720b8377e5d7fb58fdcd095c7 to your computer and use it in GitHub Desktop.
Save jtomchak/c251b2a720b8377e5d7fb58fdcd095c7 to your computer and use it in GitHub Desktop.
// source http://jsbin.com
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="timeoutLoop">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
const arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
setTimeout(function() {
console.log('The index of this number is: ' + i);
}, 3000);
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">const arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
setTimeout(function() {
console.log('The index of this number is: ' + i);
}, 3000);
}</script></body>
</html>
const arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
setTimeout(function() {
console.log('The index of this number is: ' + i);
}, 3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment