Fun trivia: setTimeout can have more than two arguments. After the callback function, and the duration, you can pass args for the callback, as well. Instead of working aroundsetTimeout, usesetTimeout.
for (var i = 0; i < 10; i++) {
setTimeout(console.log, 100*i, i);
}
(Although I don't even write the for loop, like, ever. It's all map, filter, reduce etc. So I'd rewrite it into something like this:
Fun trivia:
setTimeout
can have more than two arguments. After the callback function, and the duration, you can pass args for the callback, as well. Instead of working aroundsetTimeout
, usesetTimeout
.(Although I don't even write the
for
loop, like, ever. It's allmap
,filter
,reduce
etc. So I'd rewrite it into something like this: