There's an integer type array. I added an element to the .push() method. Isn't there the simplest way to remove certain elements of an array? array.remove(int); like this.
I'm not using any framework, I'm just using JavaScript.
array javascript
First, find the index of the element that you want to erase.
var array = [2, 5, 9];
var index = array.indexOf(5);
However, indexOf is not supported on Internet Explorer 7 and 8.
if (index > -1) {
array.splice(index, 1);
}
In this way, use splice to erase it. The second parameter in the splice indicates the number of elements to erase. The example above means that we're going to erase only one from the first parameter.
© 2024 OneMinuteCode. All rights reserved.