Yes, I've seen this asked and answered before. But here's what I still don't understand:
If I create a constructor function, and don't override the function's prototype property, then we have the automatic constructor property hanging off the function's prototype property. That is MyConstructor.prototype.constructor === MyConstructor => true. Great. But now what happens when I override prototype with my own object, and don't patch up the constructor property? constructor now doesn't exist on prototype, and if referenced is only found up the prototype chain, that is MyConstructor.prototype.constructor === Object => true. Fine. So...
Why is it that in a Javascript debugger (like Chrome), if I override a constructor's prototype with my own object, and new up an instance of that constructor, and then type that instance variable on the command line, Chrome happily tells me the type? How does it know??? I.e. what can I do to find out the same thing through code?
Simple repro:
> function Foo() {}
undefined
> Foo.prototype.constructor === Foo
true
> Foo.prototype = {}
Object
> Foo.prototype.constructor === Foo
false
> f = new Foo()
Foo
> f
Foo
Is it pure debugger magic?
 
    