Spoiler: V8's default array implementation holds pointers to boxed objects [Questions 5 & 6], but there are special-case implementations for arrays of doubles [1] and 16-bit integers [9] (and presumably others). However, adding a single string to an array of doubles violates the special-case and requires every double to be boxed, significantly increasing memory footprint [2].<p>It's interesting to compare this to a "NaN-boxing" approach, which allows pointers and doubles (and other simple values) to all exist in a single "namespace" of 8-byte values. In the (uncommon?) case of a heterogeneous array, this can save memory by avoiding the need to box simple values. The downside is that NaN-boxing prevents the use of full 64-bit pointers.
This is one of my favourite ways to play with a concept. The quiz part forces my brain to turn on the problem solving section rather than just the reading section.
Okay, but how about other JavaScript engines?<p>And shouldn't stuff like this be in the specs, so that the language becomes more consistent and predictable?
So V8 doesn't use compressed pointers? It sounds wasteful to use whole 8 bytes for pointer if typical JS application is unlikely to need more than 2GB of ram