contains
优质
小牛编辑
146浏览
2023-12-01
Checks whether the given value is in this sequence.
Signature
Sequence.contains = function(value, equalityFn) { /*...*/ }
Sequence.contains = function contains(value, equalityFn) { return this.indexOf(value, equalityFn) !== -1; }
Name | Type(s) | Description |
---|---|---|
value | * | The element to search for in the sequence. |
equalityFn | Function? | An optional equality function, which should take two arguments and return true or false to indicate whether those values are considered equal. |
returns | boolean | True if the sequence contains the value, false if not. |
Examples
var numbers = [5, 10, 15, 20]; Lazy(numbers).contains(15) // => true Lazy(numbers).contains(13) // => false