Re:JS MythBusters – An optimization handbook from a high lev...
by recursive on Tuesday August 30, 2016 @05:47PM
(#12394206)
I'm not saying it's not true. I don't know enough deep javascript magic to make that claim. It just didn't sound true, given that they've provided no supporting information or even a plausible-sounding explanation of why one way is better than another way.
If the entire site were rewritten using this level of detail plus benchmarks, it would be 10x more useful.
On SpiderMonkey, deleting a property that isn't the last one that was defined may incur a "dictionary mode" conversion [0]. This means the information describing each object property, which is usually immutable and shared between similar objects, will be copied one-by-one into a unique chain owned by the particular object instance. This can only happen once per object instance, however, and subsequent usages of `delete` on its properties will be less expensive -- but still more expensive than simply setting property values to `null`. I believe something similar happens with V8's "hidden classes" mechanism.
[0] https://dxr.mozilla.org/mozilla-central/source/js/src/vm/Sha...