Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Person(){}
- Person.prototype.dance = function(){};
- function Ninja(){}
- // Achieve similar, but non-inheritable, results
- Ninja.prototype = Person.prototype;
- Ninja.prototype = { dance: Person.prototype.dance };
- console.log( (new Ninja()) instanceof Person);
- // Only this maintains the prototype chain
- Ninja.prototype = new Person();
- var ninja = new Ninja();
- console.log( ninja instanceof Person );
Add Comment
Please, Sign In to add comment