[JavaScript] How to merge two arrays?


I want to merge two arrays, how can we do that in Javascript?

1 Answer

3 years ago by

You can use ES6 feature, spread operator to merge the arrays like below

const num3 = [...num1, ...num2];

Try running the above solution here https://onecompiler.com/javascript/3xmvzgekv

3 years ago by Meera