constructor Property

When an object is created, a special property is assigned to it behind the scenes-the constructor property. It contains a reference to the constructor function used to create this object.

Continuing from the previous example:



The constructor property contains a reference to a function. You can call this function to produce a new object.

var h3 = new h2.constructor('Rafaello');;

If an object was created using the object literal notation(), its constructor is the built-in Object() constructor function.

var o = {};


typeof o.constructor;
Related Tutorial
Follow Us #
Contents +