Lodash——without 方法
語法
_.without(array, [values])
使用 SameValueZero 進行相等性比較,建立一個不包含所有給定值的陣列。
引數
array (陣列) − 要檢查的陣列。
[values] (...*) − 要排除的值。
輸出
(陣列) − 返回過濾值的新陣列。
示例
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 ]
lodash_array.htm
廣告