Changing constructor in JavaScript

前端 未结 3 735
醉酒成梦
醉酒成梦 2020-12-11 19:41

I am trying for a while to switch constructor for a object and I am failing. Continuing code will show example of what I need. Thanks.

    

        
3条回答
  •  旧巷少年郎
    2020-12-11 19:45

    The Me.prototype.constructor property is just a public property of Me.prototype, it is not used in any way in the construction of new objects or resolution of property names.

    The only vague interest it has is that intially it references the function that its prototype "belongs" to and that instances of Me inherit it. Because it is a public property that can easily be assigned a new value or shadowed, it is not particularly reliable unless you have tight control over it and the code using it.

提交回复
热议问题