A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/String/substr below:

substr ยท WebPlatform Docs

substr Summary

Gets a substring beginning at the specified location and having the specified length.

Syntax
stringvar.substr( start [, length ])
stringvar
Required. A string literal or String object from which the substring is extracted.
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.
Examples

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 Attributions

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