startsWith
优质
小牛编辑
135浏览
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; }
Name | Type(s) | Description |
---|---|---|
prefix | string | The prefix to check for. |
returns | boolean | Whether or not this sequence starts with |
Examples
Lazy('foo').startsWith('fo') // => true Lazy('foo').startsWith('') // => true Lazy('foo').startsWith('abc') // => false