How to delete array elements in Javascript
To delete array elements in Javascript, you can either use delete or splice. The difference is that use of delete leaves “holes” in the array …
This removes the “c” element. The index of the subsequent elements remains as before.
Using splice shifts the array elements …
The “c” element is removed and the subsequent elements are shifted to fill that hole. Hence their array indices change. And that is why myArray[2] is returning something.