Re:JavaScript is Dead. Long Live JavaScript
by bzbarsky on Monday June 27, 2011 @12:00AM
(#2700050)
Actually, the forEach version can end up faster than the let version... especially if you self-host forEach so that the JIT can do its job (e.g. inlining the LIB_addEventListener calls so there aren't actually any function invocations, etc).
[ Parent
| on HN ]
> Actually, the forEach version can end up faster than the let version...
Theoretically maybe, but I've yet to see that. A regular `for(;;)` is generally 3-5 times faster than using `Array.prototype.forEach`.
Re. JIT, hand-rolling a foreach in javascript can be up to twice as fast as the native one, depending on the features you leave out.
Re:JavaScript is Dead. Long Live JavaScript
by bzbarsky on Tuesday June 28, 2011 @02:56PM
(#2706748)
> Theoretically maybe, but I've yet to see that
Compare the let version to the code in https://bugzilla.mozilla.org/show_bug.cgi?id=602132