String.substr

substr — Extracts a specified number of characters in a string, from a start index.

Description

String.substr(integer begin, [integer length])

Parameters

Name Description Type Default Optional
begin Positive values count from beginning of string, whele negative count from the end. integer No
length integer Yes

Return values

string primitive.

Examples

Example #1 – substr example
console.log('Hello World'.substr(1)); // ello World console.log('Hello World'.substr(-1)); // d console.log('Hello World'.substr(1, 9)); // ello Worl console.log('Hello World'.substr(-4, 3)); // orl console.log('Hello World'.substr(0, 1)); // H

See also

External references