Joined July 2012
·

Herson Salinas

Honduras
·
·
·

Posted to Be careful with setTimeout in loops over 1 year ago

@flipecoelho On the very last example, them both work the same, only that I use anonymous functions

Posted to Be careful with setTimeout in loops over 1 year ago
for (var i = 1; i <= 5; ++i) {
    (function(n) {
        setTimeout(function(){
            console.log(n);
        }, 1000);
    }(i));
}

What happens if I change the time of the system clock at any moment between those steps?

Posted to The single most useful thing in bash over 1 year ago

mind = blow

Achievements
59 Karma
3,199 Total ProTip Views