Categories
JavaScript Answers

How to concatenate N arrays with JavaScript?

Spread the love

To concatenate N arrays with JavaScript, we use the spread operator and push.

For instance, we write

const a = [1, 2],
  b = ["x", "y"],
  c = [true, false];
a.push(...b, ...c);

to call a.push with the entries from b and c spread as arguments to put the entries into a.

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 *