A Tricky JavaScript Interview Question Asked by Google and Amazon
Daniel Borowski
6.3K30

i personally think you should mention a ES5 solution too since browsers wont understand your solution:

var arr = [10, 12, 15, 21];
for (var i = 0; i < arr.length; i++) {
 setTimeout(function(j) {
 var i = this;
 console.log(‘Index: ‘ + i + ‘, element: ‘ + arr[i]);
 }.bind(i), 1000);
}

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.