I'm doing a simple exercise to do iteratively or with the method concat
, which consists of joining 2 arrays and returning the joined as a new array , but I can't, this is the code I have, as a premise, it must be in one line, hence it does not end up solving it.
Array.prototype.concatenar = function(vector) {
let nuevoVector = this;
nuevoVector.push.apply(this, vector);
return nuevoVector;
};
I don't understand how to resolve in a new array or obtain a result of joining them and returning it in the same line, I have tried the method map
of traversing the received vector and adding it to the vector this
, but nothing...
You can use the operator
...
with theArrays
:DOCUMENTATION
EDIT
You can even make a function that concatenates more than one
Array
:I think what you want to do is this...