Easy Tutorial
❮ Prop Fieldset Disabled Jsref Decodeuricomponent ❯

JavaScript startsWith() Method

JavaScript String Object

Example

Check if the string starts with "Hello":

n Output result:


Definition and Usage

The startsWith() method is used to determine whether a string begins with the characters of a specified string.

It returns true if the string starts with the specified characters, otherwise false.

The startsWith() method is case-sensitive.


Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
startsWith() 41 12.0 17 9 28

Syntax

string.startsWith(searchvalue, start)

Parameter Values

Parameter Description
searchvalue Required. The string to search for.
start Optional. The position to start the search. Default is 0.

Return Value

Type Description
Boolean Returns true if the string starts with the specified characters, otherwise false.

Technical Details

| JavaScript Version: | ECMAScript 6 | | --- | --- |


More Examples

Example

Check if the string starts with "world" from the 6th index position:

n Output result:


JavaScript String Object

❮ Prop Fieldset Disabled Jsref Decodeuricomponent ❯