1function removeItemOnce(arr, value) {
2 var index = arr.indexOf(value);
3 if (index > -1) {
4 arr.splice(index, 1);
5 }
6 return arr;
7}
8
9function removeItemAll(arr, value) {
10 var i = 0;
11 while (i < arr.length) {
12 if (arr[i] === value) {
13 arr.splice(i, 1);
14 } else {
15 ++i;
16 }
17 }
18 return arr;
19}
20//Usage
21console.log(removeItemOnce([2,5,9,1,5,8,5], 5))
22console.log(removeItemAll([2,5,9,1,5,8,5], 5))