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

endsWith

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

Checks if this sequence ends with a given suffix.

Signature

StringLikeSequence.endsWith = function(suffix) { /*...*/ }
StringLikeSequence.endsWith = function endsWith(suffix) {
  return this.substring(this.length() - suffix.length).toString() === suffix;
}
NameType(s)Description
suffixstring

The suffix to check for.

returnsboolean

Whether or not this sequence ends with suffix.

Examples

Lazy('foo').endsWith('oo')  // => true
Lazy('foo').endsWith('')    // => true
Lazy('foo').endsWith('abc') // => false