Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manekinekko/d468cb3ef06505556b138198f8b92d91 to your computer and use it in GitHub Desktop.
Save manekinekko/d468cb3ef06505556b138198f8b92d91 to your computer and use it in GitHub Desktop.
function Force() {}
Jedi.prototype.toString = function () {
return 'I am the Force';
};
function Jedi() {}
Jedi.prototype = Force.prototype;
Jedi.prototype.toString = function () {
return 'I am a Jedi';
};
const luke = new Jedi();
const force = new Force();
console.log(luke instanceof Jedi); //=> true
console.log(luke instanceof Force); //=> true
console.log(luke + ''); //=> 'I am a Jedi'
console.log(force + ''); //=> 'I am a Jedi' <=== OH OH !!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment