Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Facts (credits go to @IHateLazy): </p> <p><code>aspenProto.constructor</code> is <code>Mammal</code>. This is because the <code>constructor</code> is actually an attribute of Mammal.prototype, set at the method creation time. <code>Canine.prototype.constructor</code> is not <code>Canine</code>, since the prototype (holding the <code>constructor</code> property) was overwritten by <code>new Mammal()</code>.</p> <p>Tests:</p> <pre><code>aspen.constructor = function Hello(){}; // aspen is Hello in Firebug, // Dog in Chrome aspen.constructor.name = "test" // still Hello in Firebug, // name is also Hello in both aspen.constructor = function(){}; // aspen is Object in Firebug aspen.constructor.name = "test" // still Object in Firebug aspen.constructor = null; // still Object and Dog ({constructor: function Hello(){}}) // Hello in Firebug AND Chrome ({constructor: function (){}}) // Object in both (not surprisingly) ({constructor:{name:"Hi"}}) // "Object" in FB, "Hi" in Chrome x={constructor:function(){}) x.constructor.name="Hello" // x is Object in both x=new Object() x.constructor=function Hello(){} // x is Hello in both new (function(){})() // Object in both new (function(){ this.constructor=function Hello(){} })() // Hello in both </code></pre> <p>Conclusion:</p> <p>Firebug always relies on the object's own <code>constructor</code> property to name it. If the <code>constructor</code> is a named function, it uses the <code>constructor</code> <code>name</code> (which is not writable - thanks @IHateLazy). If the <code>constructor</code> property is an anonymous function or not a function at all, then Firebug uses <code>"Object"</code> instead.</p> <p>Chrome holds each object's actual constructor as an internal property. <em>Only</em> if that property is not accessible (the object was not constructed) or is Object, it looks at the object's <code>constructor</code> property. If the constructor is a named function, it uses its internally stored name. If the constructor is not a function or is anonymous it uses the <code>name</code> property.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload