Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manekinekko/18554251853ac66361df4b457290e0b3 to your computer and use it in GitHub Desktop.
Save manekinekko/18554251853ac66361df4b457290e0b3 to your computer and use it in GitHub Desktop.
function Jedi() {}
Jedi.prototype.useForce = function () {
console.log('I am using the force!');
};
const anakin = Jedi();
const luke = new Jedi();
console.log(anakin instanceof Jedi); //=> false
console.log(typeof anakin.useForce); //=> TypeError: anakin is undefined
console.log(luke instanceof Jedi); //=> true
console.log(typeof luke.useForce); //=> 'function'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment