News for hackers. Stuff that matters.
Re:Poll: Suggestions please, which JavaScript library? by nostrademons on Sunday June 08, 2008 @04:06PM (#212262)
$.map has an interesting quirk in its spec: it flattens returned arrays into the result. This was implemented by calling concat() with each result, but concat creates a new array for its return value. So each iteration was creating a new array and copying over the previous values, which makes for a quadratic runtime in most JS runtimes.

(Curiously, in the benchmarks folks did in the Reddit thread, it looked like Firefox was not quadratic - which implies that Firefox either has some clever optimizations going on or does crazy things with concat().)

There are no comments on this comment yet.