Merge two json/javascript arrays in to one array

javascript, jquery, json

Solution

You want the `concat` method.

var finalObj = json1.concat(json2);

Problem

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' ...}] ```

Original source