Why is mutating the [[prototype]] of an object bad for performance?

后端 未结 4 1994
礼貌的吻别
礼貌的吻别 2020-11-22 14:36

From the MDN docs for the standard setPrototypeOf function as well as the non-standard __proto__ property:

Mutating the [[Prototype]] of an

4条回答
  •  悲哀的现实
    2020-11-22 15:09

    Yes .prototype= is just as bad, hence the wording "no matter how it is accomplished". prototype is a pseudo object for extending the functionality at the class level. Its dynamic nature slows down script execution. Adding a function on the instance level, on the other hand, incurs far less overhead.

提交回复
热议问题