To remove an element from an array. First, we need to find the index of the element you wish to remove.

var array = [100, 200, 300];
var index = array.indexOf(300);

if (index > -1) {
    array.splice(index, 1);
}

console.log(array);

Then remove it with splice()

Output

(2) [100, 200]
Last modified: January 12, 2018

Author