Murtaza Khursheed Hussain Murtaza Khursheed Hussain - 4 months ago 7
jQuery Question

Merge two json/javascript arrays in to one array

I have two json arrays like

var json1 = [{id:1, name: 'xxx' ...}]
var json2 = [{id:2, name: 'xyz' ...}]


I want them merge in to single arrays

var finalObj = [{id:1, name: 'xxx' ...},{id:2, name: 'xyz' ...}]


Regards

Answer

You want the concat method.

var finalObj = json1.concat(json2);
Comments