5 ms·
http://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/obje
by swannodette 16y ago
http://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.