substr() string method extracts a range of characters from a string. The
substr() method is passed two values: the first number is an index number where to start the extraction and the second number is the amount of characters to extract after the index number. Keep in mind that the first character in the string is at index
0. If the second number is missing, then the
substr() method returns the rest of the string past the index that was given. The
substr() method does not actually change the original string. It just returns a portion of it.
Here is an example:
var example_string = "My name is Dusty"; var first_name = example_string.substr(11,3); document.write(first_name);
In this example
Dus is written to the screen.