Created
January 22, 2017 13:46
-
-
Save hafeez-syed/575b5a95b9b756e542731c407408026a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var animal = { | |
kind: 'human' | |
}; | |
console.log(animal); | |
var hafeez = {}; | |
hafeez.__proto__ = animal; | |
console.log(hafeez.kind); | |
console.log(animal.isPrototypeOf(hafeez)); | |
animal.kind = 'igloo'; | |
console.log(hafeez.kind); | |
console.log(animal.kind); | |
// Use Object.create instead of `__proto__` | |
hafeez = Object.create(animal, {food: {value:"mango"}}); | |
console.log(hafeez.kind, animal.kind); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment