constructor

  • property
can.Construct.prototype.constructor

{Object}

 

A reference to the constructor function that created the instance. This allows you to access the constructor's static properties from an instance.

Object

Example

This can.Construct has a static counter that counts how many instances have been created:

var Counter = can.Construct.extend({
    count: 0
}, {
    init: function() {
        this.constructor.count++;
    }
});

var childCounter = new Counter();
console.log(childCounter.constructor.count); // 1
console.log(Counter.count); // 1