News for hackers. Stuff that matters.
Re:What's wrong with this code, really? by bzbarsky on Friday September 16, 2011 @06:45PM (#3006617)
JS arrays are implemented in a variety of ways in different JS engines, but at least V8 and Spidermonkey have a "fast case" where there's an actual C array (single contiguous chunk of memory) and fall back on a slower representation in the rare cases (large holes in the array, non-integer indices, etc).

So in the common case, you are in fact looking at a big memcpy every time you remove an object from the front, unless you do some magic with keeping track of a nonzero offset in your C array. V8 does that magic in some cases but not others, as far as I can tell.

Re:What's wrong with this code, really? by thaumaturgy on Friday September 16, 2011 @07:12PM (#3006684)
Thanks! That explains a lot. I'm actually really surprised that they're implemented that way (pleasantly surprised) -- I didn't think even "high performance" code was generally done like that anymore.