News for hackers. Stuff that matters.
Re:Long live the callbacks by Zikes on Thursday August 22, 2013 @11:05AM (#6257559)
In the first example the genPrimes function is being created 2e4 times, once for each iteration of the loop. In the second example it's defined once.
Re:Long live the callbacks by lewispollard on Thursday August 22, 2013 @11:11AM (#6257596)
Yep, if you use jshint/lint it'll warn you about creating functions within a loop. The performance difference is more to do with that than any inherent flaws in using anonymous functions as callbacks.