Categories
JavaScript Answers

How to combine or merge JSON on Node.js?

Spread the love

To combine or merge JSON on Node.js, we use the spread operator.

For instance, we write

const o1 = { a: 1 };
const o2 = { b: 2 };
const obj = { ...o1, ...o2 };

to create the obj object by spreading the properties of o1 and o2 into a new object.

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 *