Gets a substring beginning at the specified location and having the specified length.
Syntaxstringvar.substr( start [, length ])
The following example illustrates the use of the substr method.
var s = "The quick brown fox jumps over the lazy dog.";
var ss = s.substr(10, 5);
document.write("[" + ss + "] <br>");
ss = s.substr(10);
document.write("[" + ss + "] <br>");
ss = s.substr(10, -5);
document.write("[" + ss + "] <br>");
ss = s.substr(-4);
document.write("[" + ss + "] <br>");
Remarks
If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar. If start is negative, it is treated as [stringvar.length+start] if length is omitted this would return the last `start` characters of the stringvar.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4