// delete an item from the array function remove(arr, item) { if (arr.length) { //Continue to judge whether the array has a value or not var index = arr.indexOf(item); // Get the index of the value to be deleted and assign it to index if (index > -1) { // if the entered value exists Note: the value not found in the array is -1 arr.splice(index, 1); // then delete the input value } } }