在JavaScript中突变对象原型
属性,或在其创建后突变原型链突变,但由于其严重的性能含义。现代JavaScript引擎最佳访问基于对象的内部类型和其原型链。修改原型链会使这些优化无效,从而导致执行时间较慢。与原型上的各个属性不同,例如foo.prototype.bar,重新签名
Check the entire prototype chain for cycles
Flush property lookup optimizationsDiscard precompiled codeFall back to slower, unoptimized code
To avoid the performance issues associated with prototype mutation, consider these alternatives:
Create new objects with the desired prototype chain using object.create()使用foo.prototype.bar = bar [&& && && && && &&华
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3