Categories
JavaScript Answers

How to merge two JSON or JavaScript arrays in to one array?

Spread the love

Sometimes, we want to merge two JSON or JavaScript arrays in to one array.

In this article, we’ll look at how to merge two JSON or JavaScript arrays in to one array.

How to merge two JSON or JavaScript arrays in to one array?

To merge two JSON or JavaScript arrays in to one array, we use the concat method.

For instance, we write

const finalArr = json1.concat(json2);

to call json1.concat with the json2 array to return a new array with the entries of the json1 and json2 entries.

Conclusion

To merge two JSON or JavaScript arrays in to one array, we use the concat method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *