String.substring

substring — Extracts the chars in a string between two specified indexes.

Description

String.substring(integer start, [integer stop])

Parameters

Name Description Type Default Optional
start integer No
stop integer Yes

Return values

string primitive.

Examples

Example #1 – substring example
console.log('Hello World'.substring(1)); // ello World console.log('Hello World'.substring(10)); // d console.log('Hello World'.substring(1, 10)); // ello Worl console.log('Hello World'.substring(7, 10)); // orl console.log('Hello World'.substring(0, 1)); // H

See also

External references