loading...

re: Find and Replace elements in Array with JavaScript VIEW POST

FULL DISCUSSION
 

Array.prototype.splice is really cool. I think it's worth to mention that you actually can do a replace with a third argument:

const arr = [1,2,3,4,5];
arr.splice(1, 1, 0);
arr;
// [1,0,3,4,5]

Code of Conduct Report abuse