Created
December 22, 2019 05:41
-
-
Save bhaveshdaswani93/5eae6d9c46872d09f61233f3f7028777 to your computer and use it in GitHub Desktop.
This shows an example of how Object.create is use to create prototype
This file contains 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
let person = { | |
first_name:'lorem', | |
last_name:'ipsum', | |
getFullName(){ | |
return `Fullname is ${this.first_name} ${this.last_name}`; | |
} | |
} | |
let personA = Object.create(person); | |
personA.first_name = 'ullamcorper'; //overwrite the person first_name property | |
personA.last_name = 'ipsum'; //overwrite the person last_name property | |
personA.getFullName(); // output Fullname is ullamcorper ipsum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment