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

startsWith

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

Checks if this sequence starts with a given prefix.

Signature

StringLikeSequence.startsWith = function(prefix) { /*...*/ }
StringLikeSequence.startsWith = function startsWith(prefix) {
  return this.substring(0, prefix.length).toString() === prefix;
}
NameType(s)Description
prefixstring

The prefix to check for.

returnsboolean

Whether or not this sequence starts with prefix.

Examples

Lazy('foo').startsWith('fo')  // => true
Lazy('foo').startsWith('')    // => true
Lazy('foo').startsWith('abc') // => false