Answers for "javascript array extend"

1

javascript extend array

The .push method can take multiple arguments. You can use the spread operator to pass all the elements of the second array as arguments to .push:

>>> a.push(...b)
If your browser does not support ECMAScript 6, you can use .apply instead:

>>> a.push.apply(a, b)
Or perhaps, if you think it's clearer:

>>> Array.prototype.push.apply(a,b)
Posted by: Guest on October-01-2020
0

javascript array extend

>>> a.push(...b)
Posted by: Guest on October-10-2021
-1

array javascript extend

var a = [1, 2, 3];
a = a.concat([5, 4, 3]);
Posted by: Guest on May-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language