What is the most elegant way for js to add another array to the end of the array?

is there a method like push, but instead of inserting an element into an array, add another array
similar to java"s addAll method

all I know so far is concat, but he returns the new array instead of making changes on the original array,

Mar.06,2021

let arr = [1, 2];
arr.push(...[3, 4]);

if you use the ES6, method, you should be able to push (.newarr)


there are about three things I know:

  • a.concat (b)
  • Array.prototype.push.apply (a, b)
  • a.push (.b)

what do you mean by this elegant standard


let arr = [1 hr class= 2 answer 3]
[] .push.apply (arr, [4je 5J 6])


the most elegant thing should be the direct extension operator ~:

const d = ['1','2'];
const x = ['3','4'];
const a = [...d, ...x];
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e92699-4719c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e92699-4719c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?