Created
November 24, 2018 23:02
-
-
Save manekinekko/90321bcdf1e6e28f6c6f109ba551f0ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Jedi() { | |
this.useForce = function () { | |
return 'I am the Instance'; | |
}; | |
} | |
// 1) nous attachons la méthode "useForce" au prototype | |
Jedi.prototype.useForce = function () { | |
return 'I am the Prototype'; | |
}; | |
// 2) nous créons une instance | |
const luke = new Jedi(); | |
console.log(luke.useForce()); //=> 'I am the Instance' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment