every
优质
小牛编辑
128浏览
2023-12-01
Checks whether every element in this sequence satisfies a given predicate.
Signature
Sequence.every = function(predicate) { /*...*/ }
Sequence.every = function every(predicate) { predicate = createCallback(predicate); return this.each(function(e, i) { return !!predicate(e, i); }); }
Name | Type(s) | Description |
---|---|---|
predicate | Function | A function to call on (potentially) every element in this sequence. |
returns | boolean | True if |
Examples
var numbers = [1, 2, 3, 4, 5]; var objects = [{ foo: true }, { foo: false, bar: true }]; Lazy(numbers).every(isEven) // => false Lazy(numbers).every(isPositive) // => true Lazy(objects).all('foo') // => false Lazy(objects).all('bar') // => false