24.176. String.substring( ): return a substring of a stringECMAScript v124.176.1. Synopsisstring.substring(from, to) 24.176.1.1. Arguments
24.176.1.2. ReturnsA 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. 24.176.2. DescriptionString.substring( ) returns a substring of string consisting of the characters between positions from and to. The character at position from is included, but the character at position to is not included. If from equals to, this method returns an empty (length 0) string. If from is greater than to, this method first swaps the two arguments and then returns the substring between them. 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. While this may seem arbitrary or counterintuitive, a notable feature of this system is that the length of the returned substring is always equal to to-from. Note that String.slice( ) and the nonstandard String.substr( ) can also extract substrings from a string. Unlike those methods, String.substring( ) does not accept negative arguments. 24.176.3. See AlsoString.charAt( ), String.indexOf( ), String.lastIndexOf( ), String.slice( ), String.substr( ) |