ReturnValue
Use to overwrite the return value of new Construct(...).
new Construct.ReturnValue( value )
This constructor function can be used for creating a return value of the setup
method.
can-construct will check if the return value is an instance of Construct.ReturnValue
.
If it is then its value
will be used as the new instance.
Parameters
- value
{Object}
:A value to be used for a new instance instead of a new object.
var Student = function( name, school ){ this.name = name; this.school = school; } var Person = Construct.extend({ setup: function( options ){ if (options.school){ return new Constructor.ReturnValue( new Student( options.name, options.school ) ); } else { return [options]; } } }); var myPerson = new Person( {name: "Ilya", school: "PetrSU"} ); myPerson instanceof Student // => true