Re:Long live the callbacks
by marijn on Thursday August 22, 2013 @11:12AM
(#6257609)
JavaScript functions have identity, so creating anonymous functions, even if they don't close over anything, actually requires a garbage-collected object to be allocated, rather than just creating a pointer to a piece of code.
Doing this in inner loops is going to cause a noticeable performance degradation. (Doing it in expensive asynchronous operations, which is what callbacks are often used for, is not going to make a measurable difference.)
Re:Long live the callbacks
by seldo on Thursday August 22, 2013 @11:16AM
(#6257629)
Oh. I was expecting it to be some javascript-y reason rather than a mere big-O calculation :-P Forgive me, I flew cross-country overnight and am operating on not much sleep :-)
Doing this in inner loops is going to cause a noticeable performance degradation. (Doing it in expensive asynchronous operations, which is what callbacks are often used for, is not going to make a measurable difference.)