Yet another "how to find the class/constructor name of a Javascript object"?
<p>Yes, I've seen this asked and answered before. But here's what I still don't understand:</p>

<p>If I create a constructor function, and don't override the function's <code>prototype</code> property, then we have the automatic <code>constructor</code> property hanging off the function's <code>prototype</code> property. That is <code>MyConstructor.prototype.constructor === MyConstructor</code> => true. Great. But now what happens when I override <code>prototype</code> with my own object, and don't patch up the <code>constructor</code> property? <code>constructor</code> now doesn't exist on <code>prototype</code>, and if referenced is only found up the prototype chain, that is <code>MyConstructor.prototype.constructor === Object</code> => true. Fine. So...</p>

<p>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?</p>

<p>Simple repro:</p>

<pre><code>&gt; function Foo() {}
undefined
&gt; Foo.prototype.constructor === Foo
true
&gt; Foo.prototype = {}
Object
&gt; Foo.prototype.constructor === Foo
false
&gt; f = new Foo()
Foo
&gt; f
Foo
</code></pre>

<p>Is it pure debugger magic?</p>
