substring (JavaScript)
Gets a substring.
Defined in
String (Standard - JavaScript)Parameters | Description |
---|---|
start | The beginning index, inclusive, where 0 is the first index in the string. |
end | The ending index, exclusive. Defaults to the rest of the string. |
Return value | Description |
---|---|
string | The substring. |
Examples
(1) The following example prints Moscow Tokyo (index 8 to the end).var cities = new String("Paris Moscow Tokyo");
cities.substring(8)
(2) The following example prints Moscow (index 8 to index 14, exclusive) from the string.
var cities = new String("Paris Moscow Tokyo");
cities.substring(8, 14)