What is the difference between spread operator
and array.concat()
The one difference I think is valid is that using spread operator for large array size will give you error of Maximum call stack size exceeded
which you can avoid using the concat
operator.
var someArray = new Array(600000);
var newArray = [];
var tempArray = [];
someArray.fill("foo");
try {
newArray.push(...someArray);
} catch (e) {
console.log("Using spread operator:", e.message)
}
tempArray = newArray.concat(someArray);
console.log("Using concat function:", tempArray.length)