JavaScript String substring

JavaScript String substring


JavaScript String substring() method

In this Tutorial, we will learn about JavaScript String substring() method with the help of following below:

substring()

This method returns a subset of a string object.

Syntax

String.substring(indexA, [indexB])

Parameters:

indexA: An integer between 0 and one less than the length of the string.

indexB: (optional) An integer between 0 and the length of the string.

ReturnValue: 

The string method returns the new sub string based on given parameters.

Example

Output