Standard built-ins
String.prototype.startsWith()
Tests a literal prefix at a specified normalized start; ordinary regex arguments are rejected.
Formal Syntax & Structure
javascript syntaxjavascript
text.startsWith(searchString, [position])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| searchString | String | Literal sequence to locate. |
| position | Number | Optional search start position. |
Return Value
Boolean
Whether the sequence starts there.
Working Example
Example Snippetjavascript
console.log("prepaid".startsWith("pre"));