Lodash - pull 方法

语法

_.pull(array, [values])

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

参数

  • array (Array) − 要修改的数组。

  • [values] (...*) − 要删除的值。

输出

  • (Array) − 返回数组。

示例

var _ = require('lodash');
var list = [1, 2, 3, 2, 5, 6, 2];

_.pull(list,2)
console.log(list);

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

[ 1, 3, 5, 6 ]

lodash_array.html