Last active
December 29, 2015 14:29
-
-
Save lucperkins/7684744 to your computer and use it in GitHub Desktop.
Is this really the only way to do this???
This file contains 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
var object1 = { firstName: 'Luc', lastName: 'Perkins' }; | |
var object2 = { age: 31, hobbies: ['singing', 'guitar', 'history', 'philosophy', 'programming']}; | |
for (key in object2) { | |
object1[key] = object2[key]; | |
} | |
// The result | |
{ firstName: 'Luc', | |
lastName: 'Perkins', | |
age: 31, | |
hobbies: | |
[ 'singing', | |
'guitar', | |
'history', | |
'philosophy', | |
'programming' ] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment