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
delete fruits[0]; // Changes the first element in fruits to undefined
Practice Excercise Practice now