Files
Speedtest-Tracker/conf/site/node_modules/famulus/docs/substr.md
Henry Whitaker 7d0681e77b Updated to v1.5.2
2020-06-17 18:33:53 +01:00

859 B

substr(string, start, length)

Source

Extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters. The substr() does not change the original string.

Custom Needs

Validate string type for preventing SyntaxError

Since

1.0.0

Category

String

Arguments

{String} string - The string to extract
{Number} start - The position where to start the extraction. First character is at index 0
{Number?} length - Optional. The number of characters to extract. If omitted, it extracts the rest of the string

Returns

{String} Returns extract part of a string

Example

substr('Hello World!', 0, 5)
// => 'Hello'
substr({}, 0, 5)
// => {}
substr('Hello World!', 6)
// => 'World!'