当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

contains

优质
小牛编辑
140浏览
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;
}
NameType(s)Description
value*

The element to search for in the sequence.

equalityFnFunction?

An optional equality function, which should take two arguments and return true or false to indicate whether those values are considered equal.

returnsboolean

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