Since JavaScript arrays are objects, elements can be deleted by using the JavaScript operator delete:

Example

const fruits = ["Banana", "Orange", "Apple", "Mango"];
delete fruits[0];           // Changes the first element in fruits to undefined
Using delete may leave undefined holes in the array. Use pop() or shift() instead.



Practice Excercise Practice now