Easy Tutorial
❮ Jsref Getmilliseconds Prop Search Name ❯

JavaScript substring() Method


Definition and Usage

The substring() method is used to extract characters from a string between two specified indices.

The substring returned includes the character at the start index, but does not include the character at the end index.

Syntax

Parameter Description
from Required. A non-negative integer that specifies the position of the first character to extract in the string Object.
to Optional. A non-negative integer that is one more than the position of the last character to extract in the string Object. <br>If this parameter is omitted, the substring returned will continue to the end of the string.

Browser Support

All major browsers support the substring() method.


Example

In this example, we will use substring() to extract some characters from a string:

The output of the above code is:

❮ Jsref Getmilliseconds Prop Search Name ❯