JavaScript String startsWith() method
- Duba ɗanararar split()
- Duba ɗanararar substr()
- Duba ɗanararar Manuwal Reference JavaScript String
Definition and usage
If the string starts with the specified string, then startsWith()
Method returns true
, otherwise return false
.
startsWith()
Method is case-sensitive.
See also:
Instance
Example 1
Starting from position 0:
let text = "Hello world, welcome to the universe."; text.startsWith("Hello");
Example 2
Starting from position 6:
let text = "Hello world, welcome to the universe."; text.startsWith("world", 7);
Syntax
string.startsWith(searchValue, start)
Parameter
Parameter | Description |
---|---|
searchValue | Required. The string to search for. |
start | Optional. Starting position. Default value is 0. |
Return value
Type | Description |
---|---|
Boolean value |
If the string starts with this value, return ka tsa |
Browser support
startsWith()
ni ECMAScript6 (ES6) ce gurɗe.
All browsers support ES6 (JavaScript 2015):
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
tana ce tsa | tana ce tsa | tana ce tsa | tana ce tsa | tana ce tsa |
Internet Explorer 11 (tana ce tsa) ko ba kai ce tsa startsWith()
.
- Duba ɗanararar split()
- Duba ɗanararar substr()
- Duba ɗanararar Manuwal Reference JavaScript String