Guest User

Untitled

a guest
Mar 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function MyConstructor() {
  2. var instance = function() {
  3. alert('yey');
  4. }
  5.  
  6. instance.constructor = MyConstructor;
  7. instance.__proto__ = MyConstructor.prototype;
  8.  
  9. return instance;
  10. }
  11.  
  12. MyConstructor.prototype.instanceMethod = function() {
  13. alert('woo');
  14. }
  15.  
  16. var myInstance = new MyConstructor;
  17.  
  18. alert(myInstance instanceof MyConstructor); // true
  19. myInstance.instanceMethod(); // woo
  20. myInstance(); // yey
Add Comment
Please, Sign In to add comment