Substr method
Returns a substring of the specified length starting at the specified position.
stringvar.substr(start [,length ])
Parameters
Stringvar
Required option. The string literal or String object to extract the substring from.
Start
Required option. The starting position of the desired substring. The index of the first character in the string is 0.
Length
Options are available. The number of characters that should be included in the returned substring.
Description
If length is 0 or negative, an empty string is returned. If this argument is not specified, the substring continues to the end of the stringvar .
Example
The following example demonstrates the use of the substr method.
function Substrdemo () { var S, SS; The
declares a variable. var s = "The rain in Spain falls mainly in the plain.";
ss = s.substr ( 12 , 5) ; The
gets a substring. return (SS);
returns "Spain"
. }