Can I set the type of a Javascript object?

后端 未结 5 1449
忘了有多久
忘了有多久 2021-02-02 00:15

I\'m trying to use some of the more advanced OO features of Javascript, following Doug Crawford\'s \"super constructor\" pattern. However, I don\'t know how to set and get types

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 00:22

    In Firefox only, you can use the __proto__ property to replace the prototype for an object. Otherwise, you cannot change the type of an object that has already been created, you must create a new object using the new keyword.

提交回复
热议问题