Skip to content

Instantly share code, notes, and snippets.

@bhaveshdaswani93
Created December 22, 2019 05:41
Show Gist options
  • Save bhaveshdaswani93/5eae6d9c46872d09f61233f3f7028777 to your computer and use it in GitHub Desktop.
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
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