Navigator 2.0, Internet Explorer 3.0
string.substring(from, to)
An integer that specifies the position within string of the first character of the desired substring. from must be between 0 and string.length-1.
An optional integer that is one greater than the position within string of the last character of the desired substring. to must be between 1 and string.length.
A new string, of length to-from, which contains a substring of string. The new string contains characters copied from positions from to to-1 of string.
String.substring() returns the specified substring of string. If from equals to, String.substring() returns an empty (length 0) string. If from is greater than to, this method first swaps the two arguments before proceeding.
String.substring() can be a confusing function to use. It is important to remember that the character at position from is included in the substring, but that the character at position to is not included in the substring. One notable feature of assigning the arguments this way is that the length of the returned substring is always equal to to-from.
Often it is more convenient to extract a substring of a string by specifying the start character and the desired length of the substring. You can do this with a function like the following:
function substring2(string, start, length) { return string.substring(start, start+length); }
file: /Techref/language/java/script/definitive/refp_373.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/20 04:34,
18.117.158.203:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/java/script/definitive/refp_373.htm"> [Chapter 21] Reference: String.substring()</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.