Lodash - without 方法
语法
_.without(array, [values])
使用 SameValueZero 进行相等性比较,创建一个排除所有给定值的数组。
参数
array (Array) − 要检查的数组。
[values] (...*) − 要排除的值。
输出
(Array) − 返回新的过滤值数组。
示例
var _ = require('lodash'); var numbers = [ 1, 2, 3, 4, 5 ] var result = _.without(numbers, 1, 2); console.log(result);
将上述程序保存在tester.js中。运行以下命令执行该程序。
命令
\>node tester.js
输出
[ 3, 4, 5 ]