newInstance
can.Construct.newInstance
Returns an instance of can.Construct
. This method can be overridden to return a cached instance.
Returns an instance of can.Construct
. This method can be overridden to return a cached instance.
Creates a new instance of the constructor function. This method is useful for creating new instances with arbitrary parameters. Typically, however, you will simply want to call the constructor with the new operator.
Example
The following creates a
Person
Construct and overridesnewInstance
to cache all instances of Person to prevent duplication. If the properties of a new Person match an existing one it will return a reference to the previously created object, otherwise it returns a new object entirely.