Yes, I saw how they asked and answered before. But here is what I still do not understand:
If I create a constructor function and do not redefine the property of the function prototype, then we have a property constructorthat depends on the property of the function prototype. This is MyConstructor.prototype.constructor === MyConstructor=> true. Fine. But what happens now when I redefine with prototypemy own object and do not correct the property constructor? constructornow does not exist on prototype, and if the link refers only to the prototype chain, that is MyConstructor.prototype.constructor === Object=> true. Good. So that...
Why is it in a Javascript debugger (like Chrome), if I redefine the prototype constructor with my own object and a new instance of this constructor, and then enter this instance variable on the command line, Chrome happily tells me the type? How to know this ??? That is, what can I do to find out the same with code?
Simple playback:
> function Foo() {}
undefined
> Foo.prototype.constructor === Foo
true
> Foo.prototype = {}
Object
> Foo.prototype.constructor === Foo
false
> f = new Foo()
Foo
> f
Foo
Is this pure debugger magic?
source
share