daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Dec 12th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top