Objects in JavaScript contain key-value pairs. The cost of a typical pair (using DevTools Profiler) is a reference to the key name, 8 bytes, and the cost of the object: 4 bytes for small ints, 8 bytes for numbers, references, etc.
The cost of the keys add up, especially in arrays with millions of objects.
Is there a asm.js sort of way to use typed arrays for arrays of identical objects?
Yes, I know this seems like a pain, but for a particular project, this may be required.
The sort of approach I'm thinking of is using a template JS object who's keys describes the offset into a typed array for each key's value, along with its type. For arrays of these objects, there'd be multiple of these object spans.
Thus two questions:
1 - Are my assumptions correct .. and there is no optimization in chrome/modern browsers that optimize the key costs? Possibly with constraints used here: http://www.2ality.com/2013/08/protecting-objects.html
2 - If so, is there a library for handling typed arrays as objects? Or any articles or gists etc?