To remove an item from an array in JavaScript, firstly get the item and then remove it using the splice() method. You can try to run the following code −
Example
<html> <body> <script> var array = [10, 30, 40, 80, 90]; var index = array.indexOf(90); document.write("Original array: "+array); if (index > -1) { array.splice(index, 1); } document.write("<br>New array after deletion: "+array); </script> </body> </html>
Output
Original array: 10,30,40,80,90 New array after deletion: 10,30,40,80