Returns a substring beginning at a specified location and having a specified length.
|
---|
function substr(start : Number [, length : Number]) : String |
Arguments
- start
-
Required. The starting position of the desired substring. The index of the first character in the string is zero.
- length
-
Optional. The number of characters to include in the returned substring.
Remarks
Example
The following example illustrates the use of the substr method.
В | Copy Code |
---|
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".
} |
Requirements
See Also