Skip to content

Instantly share code, notes, and snippets.

@ashwinkumar2438
Created June 19, 2021 16:56
Show Gist options
  • Save ashwinkumar2438/85151e8b562deed6857db2eda02b7c1f to your computer and use it in GitHub Desktop.
Save ashwinkumar2438/85151e8b562deed6857db2eda02b7c1f to your computer and use it in GitHub Desktop.
const person={
run(){ return `${this.name} is running.`},
sleep(){return `${this.name} is sleeping.`}
}
let woman=Object.assign( Object.create(person) , {name:'She'} ); /* @returns {
name: "She"
__proto__: Object <person>
}
*/
let man=Object.assign( Object.create(person) , {name:'He'} ); /* @returns {
name: "He"
__proto__: Object <person>
}
*/
woman.run(); // @returns "She is running."
man.sleep(); // @returns "He is sleeping."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment