Skip to content

Instantly share code, notes, and snippets.

@rpunkfu
Created January 5, 2017 15:45
Show Gist options
  • Select an option

  • Save rpunkfu/04aaf748c76bbf5e654016ddc5424972 to your computer and use it in GitHub Desktop.

Select an option

Save rpunkfu/04aaf748c76bbf5e654016ddc5424972 to your computer and use it in GitHub Desktop.
Just a quick example
const Dog = {
woof () { return `Woof! I am ${this.name}!` }
}
const Yoko = Object.assign(Object.create(Dog), { name: 'Yoko' })
const Yoshi = Object.assign(Object.create(Dog), { name: 'Yoshi' })
Yoko.woof() // Returns 'Woof! I am Yoko!'
Yoshi.woof() // Returns 'Woof! I am Yoshi!'
Dog.woof = function () { return `W000f! I am still ${this.name}, but much cooler!` }
Yoko.woof() // Returns 'W000f! I am still Yoko, but much cooler!'
Yoshi.woof() // Returns 'W000f! I am still Yoshi, but much cooler!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment