I'm trying to find the best way to replace the last N items in an array. I'm thinking of the following:
Remove the N amount of items from the array:
arr = arr.slice(-N);
Add the needed values via array.push() doing an iteration to get to the number of needed insertions like so:
for(var i=0; i<=N; i++) {
arr.push(new value);
}
Is there a more elegant solution to this?
Thanks.