-2
我想通過使用lodash的remove
速記函數從字符串數組中刪除一個元素,但它會從數組中刪除所有元素。lodash速記功能不能正常工作
var arr = ['one', 'two', 'three']
然後我嘗試刪除一個元素與
var num = 'two';
_.remove(arr, num);
但它移除所有元素。當我使用回調函數,如
_.remove(arr, function(o){
return o === num
});
有沒有人可以幫我找出這個問題嗎?
爲'.remove'是返回truthy值和JS謂語二ARG' 「二」'是truthy – Rajesh