mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-24 22:39:26 +01:00
859 B
859 B
substr(string, start, length)
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!'