我的大部分对象/函数都没有改变。如果我通过 Object.freeze(object)
卡住大部分对象,应用程序会运行得更快吗?还是完全没有区别?
最佳答案
卡住(和密封)会导致显着的性能下降,而不是跨各种浏览器的增益。就拿一个look在some jsperf benchmarks .
编辑:Here是 v8 的相关问题。
EDIT2:链接的问题已于 2014 年 12 月 10 日修复。根据修复,卡住对象没有任何性能影响。
Optimize Object.seal and Object.preventExtensions
They both now run fast (due to utilizing transitions instead of always creating new maps) and sealed or non-extensible objects can stay in fast mode after transitioning.
关于javascript - Node : Would App Run Faster if Freeze Objects?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23189516/