现在我有这个函数:
function without(array, index) {
array.splice(index, 1);
return array;
}
我认为这应该是lodash可以提供的实用程序,但看起来不是这样。
有了这个函数,我可以进行一行代码的链式操作:
var guestList = without(guests, bannedGuest).concat(moreNames);
没有办法在不使用 Lodash 的情况下实现这一点,除非引入一个谓词函数?
without
,difference
,并且它有pullAt
,它可以做你想要的事情,但返回删除的值,因此无法链接。 - Sean Vieira