Guest User

Untitled

a guest
Dec 12th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function Person(){}
  2. Person.prototype.dance = function(){};
  3.  
  4. function Ninja(){}
  5.  
  6. // Achieve similar, but non-inheritable, results
  7. Ninja.prototype = Person.prototype;
  8. Ninja.prototype = { dance: Person.prototype.dance };
  9.  
  10. console.log( (new Ninja()) instanceof Person);
  11.  
  12. // Only this maintains the prototype chain
  13. Ninja.prototype = new Person();
  14.  
  15. var ninja = new Ninja();
  16.  
  17. console.log( ninja instanceof Person );
Add Comment
Please, Sign In to add comment