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

contains

优质
小牛编辑
125浏览
2023-12-01

Checks if this sequence contains a given substring.

Signature

StringLikeSequence.contains = function(substring) { /*...*/ }
StringLikeSequence.contains = function contains(substring) {
  return this.indexOf(substring) !== -1;
}
NameType(s)Description
substringstring

The substring to check for.

returnsboolean

Whether or not this sequence contains substring.

Examples

Lazy('hello').contains('ell') // => true
Lazy('hello').contains('')    // => true
Lazy('hello').contains('abc') // => false