Skip to content

Instantly share code, notes, and snippets.

@lucperkins
Last active December 29, 2015 14:29
Show Gist options
  • Save lucperkins/7684744 to your computer and use it in GitHub Desktop.
Save lucperkins/7684744 to your computer and use it in GitHub Desktop.
Is this really the only way to do this???
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