Skip to content

Instantly share code, notes, and snippets.

@blarfoon
Last active February 22, 2022 00:15
Show Gist options
  • Save blarfoon/922c870206cfa236c55fd528258431ac to your computer and use it in GitHub Desktop.
Save blarfoon/922c870206cfa236c55fd528258431ac to your computer and use it in GitHub Desktop.
const myFirstObject = {
hi: "mom",
sayHi() {
console.log("hi " + this.hi);
},
};
const mySecondObject = Object.create(myFirstObject);
mySecondObject.hi = "medium";
console.log(mySecondObject); // > {hi: "medium"}
console.log(Object.getPrototypeOf(mySecondObject)); // > {hi: "mom", sayHi: ƒ}
mySecondObject.sayHi(); // > hi medium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment