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.
Validate string type for preventing SyntaxError
1.0.0
String
{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
{String} Returns extract part of a string
substr('Hello World!', 0, 5)
// => 'Hello'
substr({}, 0, 5)
// => {}
substr('Hello World!', 6)
// => 'World!'