Skip to content

pull

js
_.pull(array, [values])

使用 SameValueZero 进行相等比较,从 array 中删除所有给定值。

¥Removes all given values from array using SameValueZero for equality comparisons.

注意:与 _.without 不同,此方法会改变 array。使用 _.remove 通过谓词从数组中删除元素。

¥Note: Unlike _.without, this method mutates array. Use _.remove to remove elements from an array by predicate.

新增于

¥Since

2.0.0

参数

¥Arguments

  1. array (数组):要修改的数组。

    ¥array (Array): The array to modify.

  2. [values] (...*):要删除的值。

    ¥[values] (...)*: The values to remove.

返回

¥Returns

(数组):返回 array

¥(Array): Returns array.

示例

¥Example

js
var array = ['a', 'b', 'c', 'a', 'b', 'c'];

_.pull(array, 'a', 'c');
console.log(array);
// => ['b', 'b']

Lodash v4.17 中文网 - 粤ICP备13048890号