Difference between using a spread syntax (…) and push.apply, when dealing with arrays
Both Function.prototype.apply and the spread syntax may cause a stack overflow when applied to large arrays: let xs = new Array(500000), ys = [], zs; xs.fill(“foo”); try { ys.push.apply(ys, xs); } catch (e) { console.log(“apply:”, e.message) } try { ys.push(…xs); } catch (e) { console.log(“spread:”, e.message) } zs = ys.concat(xs); console.log(“concat:”, zs.length) Use Array.prototype.concat instead. … Read more