DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
      • prototype
        • constructor
        • init
        • setup
      • static
        • constructorExtends
        • extend
        • newInstance
        • setup
        • shortName
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-construct
  • /
  • constructor
  • / On this page
    • constructor

      property

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

      • source

      Object

      Example

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

      var Counter = Construct.extend({
          count: 0
      }, {
          init: function() {
              this.constructor.count++;
          }
      });
      
      var childCounter = new Counter();
      console.log(childCounter.constructor.count); // 1
      console.log(Counter.count); // 1
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.