reject
优质
小牛编辑
136浏览
2023-12-01
Creates a new sequence whose values exclude the elements of this sequence identified by the specified predicate.
Signature
Sequence.reject = function(rejectFn) { /*...*/ }
Sequence.reject = function reject(rejectFn) { rejectFn = createCallback(rejectFn); return this.filter(function(e) { return !rejectFn(e); }); }
Name | Type(s) | Description |
---|---|---|
rejectFn | Function | The predicate to call on each element in this sequence, which returns true if the element should be omitted. |
returns | Sequence | The new sequence. |
Examples
Lazy([1, 2, 3, 4, 5]).reject(isEven) // sequence: [1, 3, 5] Lazy([{ foo: 1 }, { bar: 2 }]).reject('foo') // sequence: [{ bar: 2 }] Lazy([{ foo: 1 }, { foo: 2 }]).reject({ foo: 2 }) // sequence: [{ foo: 1 }]