JavaScript String method: substr()
[this page | pdf | back links]
The substr() method (when applied to a JavaScript
string) returns
a substring defined by the start position and number of characters.
It
has the following syntax with the following parameters:
string.substr(startposition,n)
|
Parameter
|
Required / Optional
|
Description
|
|
startposition
|
Required
|
Position from where to
start returned string. First character is at position 0. If startposition
is positive and greater than or equal to string.length then returns an empty string.
If startposition is negative then indicates number of characters
before end from which to start (and if it is negative and larger in absolute
value than the length of the string then a startposition of zero is
used.
|
|
n
|
Optional
|
(default is string.length). Number of characters to
return, if omitted returns whole of rest of string
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript String Variables