2 ms·
I mean, not even under the hood. Those are just different names for the same thing.
by emodendroket 10y ago
I mean, not even under the hood. Those are just different names for the same thing.
- masklinn 10y agoDue to the way JS objects are used, modern runtime will generally try to use structures for them (e.g. "hidden classes" in V8/Chrome) rather than "general-purpose" hashmaps. Likewise JS arrays incidentally. They will often need to deoptimise back to general-purpose hashmaps, but they'll try pretty hard not to.
- emodendroket 10y agoOh. That's neat.
- masklinn 10y agoYep. V8's JIT will also try to specialise functions based on that so if you always pass the same type (where type = hidden class), a limited number of types or "anything goes". Or at least it did a few years back.
- DiThi 10y agoIf an object is being used as a hash map, you can avoid hidden class optimizations by deleting whatever from it: var map = {}; delete map.x;