4 ms·
Easy solution: don’t use them, use destructuring. // arr.push(item); // return arr; return […arr, item];
by eurasiantiger 5y ago
Easy solution: don’t use them, use destructuring.
// arr.push(item);
// return arr;
return […arr, item];
- lostcolony 5y agoThat's a slightly more wieldy way of creating a copy of the array. So still has the inefficiencies. It also is only a syntactical help with adding things onto an array; it doesn't help with removing items.