Examples: Displaying the constructor of an object
The following example creates a prototype, Tree, and an object of that type. The example then displays the constructor property for the object theTree.
function Tree(name) { this.name = name; } var theTree = new Tree('Redwood'); console.log('theTree.constructor is ' + theTree.constructor);
This example displays the following output:
theTree.constructor is function Tree(name) { this.name = name; }
All objects inherit a constructor property from their prototype.