Are frozen Objects faster ?
herby at mailbox.sk
Thu Feb 14 11:56:48 PST 2013
Andreas Rossberg wrote:
> On 14 February 2013 19:26, Herby Vojčík<herby at mailbox.sk> wrote:
>> I meant "de facto". People wanting to remove property bar from foo do not
>> write `delete foo.bar` anymore; they (at least some significant subset) have
>> learned to write `foo.bar = null;` or `foo.bar = undefined;`. The reason is
>> perf - `delete` deoptimized hidden classes.
> And with ES6, those people will hopefully realise that for those
> cases, using a Map is a cleaner alternative anyway.
No, it is another scenario. If an object is used as a Map, it should
degrade to HashMap, it's ok.
The problem is proliferation of `foo.bar = null` in "normal" code, where
sometimes you want to remove some property (maybe it was an expando, or
it is realy not needed any more in the actual phases of the lifecycle).
In such cases, doing `delete` would degrade your optimized instance into
a Hash. Thus, people do `foo.bar = null` even if what they want to do is
More information about the es-discuss