Returns a substring beginning at a specified location and having a specified length.
stringvar.substr(start [, length ])
If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar.
The following example illustrates the use of the substr method.
function SubstrDemo(){ var s, ss; //Declare variables. var s = "The rain in Spain falls mainly in the plain."; ss =s.substr(
12,
5)
; //Get substring. return(ss); // Returns "Spain". }
String Object Methods | String Object Properties | substring Method
Applies To: String Object