Is it possible to use Array.push
to add multiple values from a list? For example, currently what I'm having to do is:
Array.prototype.extend = function(arr) {
for (let elem of arr) {
this.push(elem);
}
}
let x = [1,2,3];
let y = [4,5,6];
let z = [7,8,9];
x.push(y);
x.extend(z)
console.log(x);
Or, is there some way to pass the array as a single argument to the push
method, or perhaps there's another Array method entirely that does this instead?