Created
September 27, 2012 23:39
-
-
Save ChrisMissal/3797108 to your computer and use it in GitHub Desktop.
Extending objects in jQuery
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 start = { | |
id: 123, | |
count: 41, | |
desc: 'this is information', | |
title: 'Base Object', | |
tag: 'uncategorized', | |
values: [1,1,2,3,5,8,13] | |
}; | |
var more = { | |
name: 'Los Techies', | |
tag: 'javascript' | |
}; | |
var extra = { | |
count: 42, | |
title: null, | |
desc: undefined, | |
values: [1,3,6,10] | |
}; | |
var extended = $.extend(start, more, extra); | |
console.log(JSON.stringify(extended)); |
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
{ | |
"id": 123, | |
"count": 42, | |
"desc": "this is information", | |
"title": null, | |
"tag": "javascript", | |
"values": [1, 3, 6, 10], | |
"name": "Los Techies" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment