Guest User

Untitled

a guest
Jul 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. var Factory = function (argument) {
  2. return new Factory.prototype.constructor(argument);
  3. };
  4.  
  5. Factory.prototype = {
  6. 'constructor': function (argument) {
  7. this.argument = argument;
  8. return this;
  9. }
  10. };
  11.  
  12. Factory.prototype.constructor.prototype = Factory.prototype;
  13.  
  14. // Examples...
  15. var instance = Factory('Argument');
  16. instance.argument === 'Argument';
  17. instance instanceof Factory;
  18. instance instanceof Factory.prototype.constructor;
  19.  
  20. // But...
  21. instance.constructor !== Factory;
  22. instance.constructor === Factory.prototype.constructor;
Add Comment
Please, Sign In to add comment