3 ms·
Ugh, don't agree at all with the dismissal of Object.freeze. This introduces immutable values to JS which is great for many kinds of data as well probably openi
by swannodette 16y ago
Ugh, don't agree at all with the dismissal of Object.freeze. This introduces immutable values to JS which is great for many kinds of data as well probably opening the door for more optimizations by V8.
- mraleph 16y agoCurrently doing Object.freeze closes the door for optimizations: object goes into so called slow mode. See http://jsperf.com/object-freeze http://jsperf.com/object-freeze results.
- swannodette 16y agohttp://jsperf.com/object-freeze/3 http://jsperf.com/object-freeze/3 http://jsperf.com/object-freeze/5 http://jsperf.com/object-freeze/5 http://jsperf.com/object-freeze/6 http://jsperf.com/object-freeze/6 A reminder on how immutable objects are meant to be used. When used properly even under attempts to mutate, they run circles around trying to use mutable objects in an immutable manner.
- mraleph 16y agoYeah, I did something stupid in my own test. Probably I was thinking about Object.seal(). Nevertheless your own test revision #3 shows that accesses to frozen properties are roughly 14 times slower. Revisions #5 and #6 do an allocation in the "hot" testcase so the real cost of property lookup just becomes hidden behind cost of memory management.