Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Last active December 25, 2018 17:12
Show Gist options
  • Save ivankisyov/e0dbabe080ce691f9c7cf42884316c3c to your computer and use it in GitHub Desktop.
Save ivankisyov/e0dbabe080ce691f9c7cf42884316c3c to your computer and use it in GitHub Desktop.
Object.create

Object.create

const person = {
  name: null
}

// create new object and set its __proto__ to point to person object
const ivan = Object.create(person);

// ivan will be an empty {} and can use the name property which it "inherits" from __proto__
// up to this point name is not ivan's own property, the lookup goes to person

Helpful links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment