How to remove an item from an array in Javascript
The standard way to remove an item from an array is to use indexOf (opens new window) to find the position of the item and then use splice (opens new window) to remove the item from the array.
JS
Copy code
And this works just fine if you know your array doesn't contain duplicates or you only want to remove a single instance. If your array contains duplicates and you want to remove every instance of an item, then you'll want to use a while
loop to iterate over the items and then use splice (opens new window) to remove the item.
JS
Copy code