const arr = [1,2,3];
I want to have [1,2,3,4,5,6]
using:
const arr1 = [4,5,6];
If the array is too large it takes time to use
const arr2 = [...arr, ...arr1]
How do we achieve this in JavaScript
CodePudding user response:
It could be done using the array syntax, which is faster?
const arr = [1,2,3]
const arr2 = [4,5,6]
const arr3 = _.union(arr, arr2)
console.log(arr3)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>