Monday, June 17, 2013
Jquery combine two objects values into a single object
Jquery is having inbuilt function called extend, which can be used to merge two objects values in a single object.
var data1 = { duration: 100 }; var data2 = { duration: 110 }; console.log("Before Data1 " + JSON.stringify(data1)); console.log("Before Data2 " + JSON.stringify(data2)); /* merge data2 into data1 */ $.extend(data1, data2); console.log("After Data1 " + JSON.stringify(data1)); console.log("After Data2 " + JSON.stringify(data2));
OUTPUT :
Happy Coding :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment