const myArray = [2, 5, 9];
const removeIndex = 2;
myArray.splice(removeIndex, 1);
console.log(myArray);
.splice() method can be used to delete an item from an array in Javascript. The splice method takes two required arguments. The first required parameter is the index of the item that needs to be removed and in the second parameter, you can pass as 1.
0 Comments