Created
March 28, 2016 23:19
-
-
Save natac13/b9d2a5bfff0ff229ec67 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
| // 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. | |
| // | |
| // ES5 | |
| var dog = { | |
| legs: 4 | |
| }; | |
| var fido = Object.create(dog); | |
| fido.age = 3; | |
| console.log('Fido has ' + fido.legs + ' legs!'); | |
| // ES6 for fun and since I use this most. | |
| const dog = { | |
| legs: 4 | |
| }; | |
| const fido = Object.assign( | |
| {}, | |
| dog, | |
| { age: 3 } | |
| ); | |
| 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