Remove value from array
从数组中移除值
also see removeBy
The type of elements in the array / 数组元素的类型
the array
the value to remove - 待移除的值
if true, the value is removed, false otherwise.
true
false
如果成功移除,返回 true, 否则返回 false
const arr = [1, 2, 3]remove(arr, 2) // => trueconsole.log(arr) // => [1, 3]remove(arr, 4) // => false Copy
const arr = [1, 2, 3]remove(arr, 2) // => trueconsole.log(arr) // => [1, 3]remove(arr, 4) // => false
This function mutates the original array in place. It uses Array.prototype.splice to remove the element.
Array.prototype.splice
此函数会直接修改原数组。它使用 Array.prototype.splice 移除元素。
Remove value from array
从数组中移除值
also see removeBy