public

Extending objects in jQuery

  • Download Gist
extending-objects-in-jquery-1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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));
extending-objects-in-jquery-2.js
JavaScript
1 2 3 4 5 6 7 8 9
{
"id": 123,
"count": 42,
"desc": "this is information",
"title": null,
"tag": "javascript",
"values": [1, 3, 6, 10],
"name": "Los Techies"
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.