javascript tutorial - [Solved-5 Solutions] Deleting array elements in JavaScript - delete vs splice - javascript - java script - javascript array
Problem:
How to delete array elements in JavaScript?
Solution 1:
Solution 2:
delete will delete the object property, but will not reindex the array or update its length. This makes it appears as if it is undefined:
Solution 3:
Array.remove method that I always use it in my projects.
and here's some examples of how it could be used:
Solution 4:
The length of the array won't change. Splice removes the object and shortens the array. The following code will display "a", "b", "undefined", "d"
Whereas this will display "a", "b", "d"