Skip to content

Instantly share code, notes, and snippets.

@parthdesai93
Created March 29, 2016 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parthdesai93/dd9d6101968ec8f05615ff2d7969f87b to your computer and use it in GitHub Desktop.
Save parthdesai93/dd9d6101968ec8f05615ff2d7969f87b to your computer and use it in GitHub Desktop.
a ‘dog’ object has the value of legs = 4. Create a new var named ‘fido’ as a ‘dog’ object. Set fido’s age as ‘3’ and output the number of legs that ‘fido’ has.
var dog = {
legs: 4
};
var fido = Object.create(dog);
fido.age = 3; //can define fido['age'] = 3; as well
console.log('Fido has : ' + fido.legs + ' legs!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment