Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Factory = function (argument) {
- return new Factory.prototype.constructor(argument);
- };
- Factory.prototype = {
- 'constructor': function (argument) {
- this.argument = argument;
- return this;
- }
- };
- Factory.prototype.constructor.prototype = Factory.prototype;
- // Examples...
- var instance = Factory('Argument');
- instance.argument === 'Argument';
- instance instanceof Factory;
- instance instanceof Factory.prototype.constructor;
- // But...
- instance.constructor !== Factory;
- instance.constructor === Factory.prototype.constructor;
Add Comment
Please, Sign In to add comment