I've got a complex data structure in JavaScript composed out of numbers and containers (arrays in this case). What would be the fastest and/or most memory efficient way to store and process this? Is there something non-obvious, better speed and/or memory-wise, than for example [ [ 1, 2], [3, 4] ] which requires something similar to typeof to distinguish between tree branches and leaves when scanning it? The structure is very large with about a million numbers.
I've set up a jsperf test to evaluate some methods of distinguishing between numbers and objects, and typeof seems fastest except in Opera and IE: