I'm not very experienced in javascript. I always have a question which is: why javascript array doesn't have a remove() method?
Isn't that good to have APIs as:
remove(index) : delete an item by its index and return deleted element
remove(func): delete items who match the criteria specified by the func and return a array of deleted items, for example:
let deleteStudents = studentArray.remove(s => s.age < 18);
so why there are no such useful methods in javascript and we have to use non-intuitive splice method?
There is. But the function is called splice.
To remove item at index n:
myArray.splice( n, 1 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With