The String prototype object:
Unless explicitly stated otherwise, the methods of the String prototype object defined below are not generic and the this value passed to them must be either a String value or an object that has a [[StringData]] internal slot that has been initialized to a String value.
22.1.3.1 String.prototype.at ( index )This method returns a single element String containing the code unit at index pos within the String value resulting from converting this object to a String. If there is no element at that index, the result is the empty String. The result is a String value, not a String object.
If pos
is an integral Number , then the result of x.charAt(pos)
is equivalent to the result of x.substring(pos, pos + 1)
.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.3 String.prototype.charCodeAt ( pos ) Note 1This method returns a Number (a non-negative integral Number less than 216) that is the numeric value of the code unit at index pos within the String resulting from converting this object to a String. If there is no element at that index, the result is NaN .
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
22.1.3.4 String.prototype.codePointAt ( pos ) Note 1This method returns a non-negative integral Number less than or equal to 0x10FFFF 𝔽 that is the numeric value of the UTF-16 encoded code point ( 6.1.4 ) starting at the string element at index pos within the String resulting from converting this object to a String. If there is no element at that index, the result is undefined . If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
22.1.3.5 String.prototype.concat ( ...args ) Note 1When this method is called it returns the String value consisting of the code units of the this value (converted to a String) followed by the code units of each of the arguments converted to a String. The result is a String value, not a String object.
This method performs the following steps when called:
The "length" property of this method is 1 𝔽.
Note 2This method is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
22.1.3.6 String.prototype.constructorThe initial value of String.prototype.constructor
is %String% .
This method performs the following steps when called:
This method returns true if the sequence of code units of searchString converted to a String is the same as the corresponding code units of this object (converted to a String) starting at endPosition - length(this). Otherwise it returns false .
Note 2Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.
Note 3This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.8 String.prototype.includes ( searchString [ , position ] )This method performs the following steps when called:
If searchString appears as a substring of the result of converting this object to a String, at one or more indices that are greater than or equal to position, this function returns true ; otherwise, it returns false . If position is undefined , 0 is assumed, so as to search all of the String.
Note 2Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.
Note 3This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.9 String.prototype.indexOf ( searchString [ , position ] ) Note 1If searchString appears as a substring of the result of converting this object to a String, at one or more indices that are greater than or equal to position, then the smallest such index is returned; otherwise, -1 𝔽 is returned. If position is undefined , +0 𝔽 is assumed, so as to search all of the String.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.10 String.prototype.isWellFormed ( )This method performs the following steps when called:
If searchString appears as a substring of the result of converting this object to a String at one or more indices that are smaller than or equal to position, then the greatest such index is returned; otherwise, -1 𝔽 is returned. If position is undefined , the length of the String value is assumed, so as to search all of the String.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.12 String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] )An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method returns a Number other than NaN representing the result of an implementation-defined locale-sensitive String comparison of the this value (converted to a String S) with that (converted to a String thatValue). The result is intended to correspond with a sort order of String values according to conventions of the host environment 's current locale, and will be negative when S is ordered before thatValue, positive when S is ordered after thatValue, and zero in all other cases (representing no relative ordering between S and thatValue).
Before performing the comparisons, this method performs the following steps to prepare the Strings:
The meaning of the optional second and third parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not assign any other interpretation to those parameter positions.
The actual return values are implementation-defined to permit encoding additional information in them, but this method, when considered as a method of two arguments, is required to be a consistent comparator defining a total ordering on the set of all Strings. This method is also required to recognize and honour canonical equivalence according to the Unicode Standard, including returning +0 𝔽 when comparing distinguishable Strings that are canonically equivalent.
Note 1This method itself is not directly suitable as an argument to Array.prototype.sort
because the latter requires a function of two arguments.
This method may rely on whatever language- and/or locale-sensitive comparison functionality is available to the ECMAScript environment from the host environment , and is intended to compare according to the conventions of the host environment 's current locale. However, regardless of comparison capabilities, this method must recognize and honour canonical equivalence according to the Unicode Standard—for example, the following comparisons must all return +0 𝔽:
"\u212B".localeCompare("A\u030A")
"\u2126".localeCompare("\u03A9")
"\u1E69".localeCompare("s\u0307\u0323")
"\u1E0B\u0323".localeCompare("\u1E0D\u0307")
"\u1100\u1161".localeCompare("\uAC00")
For a definition and discussion of canonical equivalence see the Unicode Standard, chapters 2 and 3, as well as Unicode Standard Annex #15, Unicode Normalization Forms and Unicode Technical Note #5, Canonical Equivalence in Applications. Also see Unicode Technical Standard #10, Unicode Collation Algorithm.
It is recommended that this method should not honour Unicode compatibility equivalents or compatibility decompositions as defined in the Unicode Standard, chapter 3, section 3.7.
Note 3This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.13 String.prototype.match ( regexp )This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.14 String.prototype.matchAll ( regexp )This method performs a regular expression match of the String representing the this value against regexp and returns an iterator that yields match results. Each match result is an Array containing the matched portion of the String as the first element, followed by the portions matched by any capturing groups. If the regular expression never matches, the returned iterator does not yield any match results.
It performs the following steps when called:
This method is intentionally generic, it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
Note 2Similarly to String.prototype.split
, String.prototype.matchAll
is designed to typically act without mutating its inputs.
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
22.1.3.16 String.prototype.padEnd ( maxLength [ , fillString ] )This method performs the following steps when called:
This method performs the following steps when called:
The abstract operation StringPaddingBuiltinsImpl takes arguments O (an ECMAScript language value ), maxLength (an ECMAScript language value ), fillString (an ECMAScript language value ), and placement ( start or end ) and returns either a normal completion containing a String or a throw completion . It performs the following steps when called:
The abstract operation StringPad takes arguments S (a String), maxLength (a non-negative integer ), fillString (a String), and placement ( start or end ) and returns a String. It performs the following steps when called:
The argument maxLength will be clamped such that it can be no smaller than the length of S.
Note 2The argument fillString defaults to " " (the String value consisting of the code unit 0x0020 SPACE).
22.1.3.17.3 ToZeroPaddedDecimalString ( n, minLength )The abstract operation ToZeroPaddedDecimalString takes arguments n (a non-negative integer ) and minLength (a non-negative integer ) and returns a String. It performs the following steps when called:
This method performs the following steps when called:
This method creates the String value consisting of the code units of the this value (converted to String) repeated count times.
Note 2This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.19 String.prototype.replace ( searchValue, replaceValue )This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.19.1 GetSubstitution ( matched, str, position, captures, namedCaptures, replacementTemplate )The abstract operation GetSubstitution takes arguments matched (a String), str (a String), position (a non-negative integer ), captures (a List of either Strings or undefined ), namedCaptures (an Object or undefined ), and replacementTemplate (a String) and returns either a normal completion containing a String or a throw completion . For the purposes of this abstract operation, a decimal digit is a code unit in the inclusive interval from 0x0030 (DIGIT ZERO) to 0x0039 (DIGIT NINE). It performs the following steps when called:
This method performs the following steps when called:
This method performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.22 String.prototype.slice ( start, end )This method returns a substring of the result of converting this object to a String, starting from index start and running to, but not including, index end (or through the end of the String if end is undefined ). If start is negative, it is treated as sourceLength + start where sourceLength is the length of the String. If end is negative, it is treated as sourceLength + end where sourceLength is the length of the String. The result is a String value, not a String object.
It performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore it can be transferred to other kinds of objects for use as a method.
22.1.3.23 String.prototype.split ( separator, limit )This method returns an Array into which substrings of the result of converting this object to a String have been stored. The substrings are determined by searching from left to right for occurrences of separator; these occurrences are not part of any String in the returned array, but serve to divide up the String value. The value of separator may be a String of any length or it may be an object, such as a RegExp, that has a %Symbol.split% method.
It performs the following steps when called:
The value of separator may be an empty String. In this case, separator does not match the empty substring at the beginning or end of the input String, nor does it match the empty substring at the end of the previous separator match. If separator is the empty String, the String is split up into individual code unit elements; the length of the result array equals the length of the String, and each substring contains one code unit.
If the this value is (or converts to) the empty String, the result depends on whether separator can match the empty String. If it can, the result array contains no elements. Otherwise, the result array contains one element, which is the empty String.
If separator is undefined , then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined , then the output array is truncated so that it contains no more than limit elements.
Note 2This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.24 String.prototype.startsWith ( searchString [ , position ] )This method performs the following steps when called:
This method returns true if the sequence of code units of searchString converted to a String is the same as the corresponding code units of this object (converted to a String) starting at index position. Otherwise it returns false .
Note 2Throwing an exception if the first argument is a RegExp is specified in order to allow future editions to define extensions that allow such argument values.
Note 3This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.25 String.prototype.substring ( start, end )This method returns a substring of the result of converting this object to a String, starting from index start and running to, but not including, index end of the String (or through the end of the String if end is undefined ). The result is a String value, not a String object.
If either argument is NaN or negative, it is replaced with zero; if either argument is strictly greater than the length of the String, it is replaced with the length of the String.
If start is strictly greater than end, they are swapped.
It performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.26 String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] )An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It works exactly the same as toLowerCase
except that it is intended to yield a locale-sensitive result corresponding with conventions of the host environment 's current locale. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings.
The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
NoteThis method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.27 String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] )An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:
This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It works exactly the same as toUpperCase
except that it is intended to yield a locale-sensitive result corresponding with conventions of the host environment 's current locale. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings.
The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.
NoteThis method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.28 String.prototype.toLowerCase ( )This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It performs the following steps when called:
The result must be derived according to the locale-insensitive case mappings in the Unicode Character Database (this explicitly includes not only the file UnicodeData.txt
, but also all locale-insensitive mappings in the file SpecialCasing.txt
that accompanies it).
The case mapping of some code points may produce multiple code points. In this case the result String may not be the same length as the source String. Because both toUpperCase
and toLowerCase
have context-sensitive behaviour, the methods are not symmetrical. In other words, s.toUpperCase().toLowerCase()
is not necessarily equal to s.toLowerCase()
.
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.29 String.prototype.toString ( )This method performs the following steps when called:
For a String object, this method happens to return the same thing as the valueOf
method.
This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It behaves in exactly the same way as String.prototype.toLowerCase
, except that the String is mapped using the toUppercase algorithm of the Unicode Default Case Conversion.
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.31 String.prototype.toWellFormed ( )This method returns a String representation of this object with all leading surrogates and trailing surrogates that are not part of a surrogate pair replaced with U+FFFD (REPLACEMENT CHARACTER).
It performs the following steps when called:
This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.32.1 TrimString ( string, where )The abstract operation TrimString takes arguments string (an ECMAScript language value ) and where ( start , end , or start+end ) and returns either a normal completion containing a String or a throw completion . It interprets string as a sequence of UTF-16 encoded code points, as described in 6.1.4 . It performs the following steps when called:
The definition of white space is the union of WhiteSpace and LineTerminator . When determining whether a Unicode code point is in Unicode general category “Space_Separator” (“Zs”), code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in 6.1.4 .
22.1.3.33 String.prototype.trimEnd ( )This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.34 String.prototype.trimStart ( )This method interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4 .
It performs the following steps when called:
This method is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
22.1.3.35 String.prototype.valueOf ( )This method performs the following steps when called:
The abstract operation ThisStringValue takes argument value (an ECMAScript language value ) and returns either a normal completion containing a String or a throw completion . It performs the following steps when called:
This method returns an iterator object that iterates over the code points of a String value, returning each code point as a String value.
It performs the following steps when called:
The value of the "name" property of this method is "[Symbol.iterator]" .
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.3