### String.prototype.substr ( start, length )
Source: https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html
Returns a substring of the string, starting at index start and running for length code units. If length is undefined, the substring extends to the end of the string. Negative start values are treated as sourceLength + start.
```APIDOC
## String.prototype.substr ( start, length )
### Description
Returns a substring of the string, starting at index start and running for length code units. If length is undefined, the substring extends to the end of the string. Negative start values are treated as sourceLength + start.
### Method
substr
### Parameters
- **start** (number) - Required - The starting index. If negative, treated as sourceLength + start.
- **length** (number) - Optional - The number of code units to include. If undefined, the substring extends to the end of the string.
### Returns
A String value containing the extracted substring.
```
--------------------------------
### Infinite loop prevention example: /(a*)b\1+/.exec("baaaac")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Another example of empty match prevention, returning ["b", ""].
```javascript
/(a*)b\1+/.exec("baaaac")
```
--------------------------------
### String.prototype.padStart ( maxLength [ , fillString ] )
Source: https://tc39.es/ecma262/multipage/text-processing.html
Documentation for the String.prototype.padStart method, which pads the start of a string to a specified length.
```APIDOC
## String.prototype.padStart ( maxLength [ , fillString ] )
### Description
Pads the current string with the given fill string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the start (left side) of the string.
### Method
padStart
### Parameters
- **maxLength** (Number) - Required - The target length of the resulting string.
- **fillString** (String) - Optional - The string to pad with. Defaults to a space (U+0020) if undefined.
### Return Value
- **String** - The padded string.
### Example
```js
"abc".padStart(10); // " abc"
"abc".padStart(10, "foo"); // "foofoofabc"
```
```
--------------------------------
### Result array for capturing parentheses example
Source: https://tc39.es/ecma262/multipage/text-processing.html
The array produced by the example above. It contains the substrings and captured groups, with undefined for the optional slash group when not present.
```javascript
["A", undefined, "B", "bold", "/", "B", "and", undefined, "CODE", "coded", "/", "CODE", ""]
```
--------------------------------
### String.prototype.substring ( start, end )
Source: https://tc39.es/ecma262/multipage/text-processing.html
Returns a substring of the string, starting from index start and running to, but not including, index end. Handles NaN, negative, and out-of-range arguments by clamping and swapping if start > end.
```APIDOC
## String.prototype.substring ( start, end )
### Description
Returns a substring of the string, starting from index start and running to, but not including, index end. If end is undefined, the substring runs to the end of the string. Handles NaN, negative, and out-of-range arguments by clamping and swapping if start > end.
### Method
substring
### Parameters
- **start** (Number) - Required - The index at which to begin extraction.
- **end** (Number) - Optional - The index before which to end extraction. If omitted, the substring runs to the end of the string.
### Returns
- **String** - The extracted substring.
### Algorithm Steps
1. Let thisValue be the this value.
2. Perform ? RequireObjectCoercible(thisValue).
3. Let string be ? ToString(thisValue).
4. Let length be the length of string.
5. Let finalStart be the result of clamping ? ToIntegerOrInfinity(start) between 0 and length.
6. Assert: If start is undefined, then finalStart is 0.
7. If end is undefined, let finalEnd be length; else let finalEnd be the result of clamping ? ToIntegerOrInfinity(end) between 0 and length.
8. Let from be min(finalStart, finalEnd).
9. Let to be max(finalStart, finalEnd).
10. Return the substring of string from from to to.
### Notes
- 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.
```
--------------------------------
### Infinite loop prevention example: /(a*)*/.exec("b")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Demonstrates that empty matches are not considered for further repetitions, preventing infinite loops.
```javascript
/(a*)*/.exec("b")
```
--------------------------------
### Example: Splitting with capturing parentheses
Source: https://tc39.es/ecma262/multipage/text-processing.html
Shows how capturing parentheses in the regular expression are spliced into the result array. The example uses /<(\/)?([^<>]+)>/ to split the string "Aboldandcoded". The result includes undefined for unmatched optional groups.
```javascript
/<(\/)?([^<>]+)>/[Symbol.split]("Aboldandcoded")
```
--------------------------------
### Choice point ordering example: /(aa|aabaac|ba|b|c)*/.exec("aabaac")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Demonstrates the choice point ordering described in Note 2, returning the array ["aaba", "ba"].
```javascript
/(aa|aabaac|ba|b|c)*/.exec("aabaac")
```
--------------------------------
### Greedy quantifier example: /a[a-z]{2,4}/.exec("abcdefghi")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Shows the result of a greedy quantifier {2,4} matching as many characters as possible, returning "abcde".
```javascript
/a[a-z]{2,4}/.exec("abcdefghi")
```
--------------------------------
### Example: Parsing the same string multiple times creates distinct parse trees
Source: https://tc39.es/ecma262/multipage/notational-conventions.html
This example shows that calling eval twice on the same string results in independent parses, each creating its own parse tree. It illustrates the note that Parse Nodes are never reused between parses.
```javascript
let str = "1 + 1;";
eval(str);
eval(str);
```
--------------------------------
### Function constructor examples with different parameter formats
Source: https://tc39.es/ecma262/multipage/fundamental-objects.html
These three expressions are equivalent and create a function that returns the sum of its parameters. They show that the Function constructor accepts parameters either as separate arguments or as a comma-separated string.
```javascript
new Function("a", "b", "c", "return a+b+c")
```
```javascript
new Function("a, b, c", "return a+b+c")
```
```javascript
new Function("a,b", "c", "return a+b+c")
```
--------------------------------
### Array.prototype.fill ( value [ , start [ , end ] ] )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Fills all elements of an array from a start index to an end index with a static value. The start and end arguments are optional and can be negative, in which case they are treated as length + start or length + end.
```APIDOC
## Array.prototype.fill ( value [ , start [ , end ] ] )
### Description
Fills all elements of an array from a start index to an end index with a static value. The start and end arguments are optional and can be negative, in which case they are treated as length + start or length + end.
### Method
fill
### Parameters
- **value** (any) - Required - The value to fill the array with.
- **start** (number) - Optional - The index to start filling from. If negative, treated as length + start. Defaults to 0.
- **end** (number) - Optional - The index to stop filling (exclusive). If negative, treated as length + end. Defaults to the length of the array.
### Return Value
Returns the modified array (the this value).
### Notes
- This method is intentionally generic; it does not require that its this value be an Array. Therefore it can be transferred to other kinds of objects for use as a method.
```
--------------------------------
### Object.getOwnPropertySymbols ( obj )
Source: https://tc39.es/ecma262/multipage/fundamental-objects.html
Gets the symbol keys of all own properties of an object.
```APIDOC
## Object.getOwnPropertySymbols ( obj )
### Description
Returns an array of all own property keys that are symbols of the given object.
### Method
CALL
### Endpoint
Object.getOwnPropertySymbols
### Parameters
- **obj** (Object) - Required - The object to inspect.
### Response
Returns an array of symbols representing the object's own property keys that are symbols.
```
--------------------------------
### Non-greedy quantifier example: /a[a-z]{2,4}?/.exec("abcdefghi")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Shows the result of a non-greedy quantifier {2,4}? matching as few characters as possible, returning "abc".
```javascript
/a[a-z]{2,4}?/.exec("abcdefghi")
```
--------------------------------
### Array.prototype.slice ( start, end )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Returns a new array containing the elements from the original array from start up to, but not including, end. If end is undefined, it goes to the end of the array. Negative start and end are treated as length + start and length + end respectively.
```APIDOC
## Array.prototype.slice ( start, end )
### Description
Returns a new array containing the elements from the original array from start up to, but not including, end. If end is undefined, it goes to the end of the array. Negative start and end are treated as length + start and length + end respectively.
### Method
slice(start, end)
### Parameters
- **start** (number) - Required - The index at which to begin extraction. If negative, treated as length + start.
- **end** (number) - Optional - The index before which to end extraction. If negative, treated as length + end. If undefined, extraction goes to the end of the array.
### Return Value
- A new array containing the extracted elements.
### Behavior
- Converts `this` to an object.
- Gets the length of the array-like object.
- Clamps start and end to valid indices.
- Creates a new array using ArraySpeciesCreate.
- Copies elements from the original array to the new array.
- Sets the length of the new array and returns it.
### Note 1
The explicit setting of the "length" property is intended to ensure the length is correct even when the new array is not a built-in Array.
### Note 2
This method is intentionally generic; it does not require that its `this` value be an Array. Therefore it can be transferred to other kinds of objects for use as a method.
```
--------------------------------
### Alternation operator `|` examples
Source: https://tc39.es/ecma262/multipage/text-processing.html
These examples illustrate the behavior of the `|` alternation operator in regular expressions. The first shows that `/a|ab/.exec("abc")` returns "a" because the left alternative is tried first. The second shows the array returned by `/((a)|(ab))((c)|(bc))/.exec("abc")`, and the third shows the array that would be returned if the right alternatives were tried first. The order in which alternatives are tried is independent of the direction of matching.
```javascript
/a|ab/.exec("abc")
```
```javascript
/((a)|(ab))((c)|(bc))/.exec("abc")
```
```javascript
["abc", "a", "a", undefined, "bc", undefined, "bc"]
```
```javascript
["abc", "ab", undefined, "ab", "c", "c", undefined]
```
--------------------------------
### String.prototype.startsWith ( searchString [ , position ] )
Source: https://tc39.es/ecma262/multipage/text-processing.html
Determines whether a string begins with the characters of a specified search string, optionally starting at a given position. Throws a TypeError if the searchString is a RegExp.
```APIDOC
## String.prototype.startsWith ( searchString [ , position ] )
### Description
Determines whether the string starts with the specified searchString, optionally starting at the given position. Throws a TypeError if searchString is a RegExp.
### Method
startsWith
### Parameters
- **searchString** (String) - Required - The characters to be searched for at the start of the string.
- **position** (Number) - Optional - The position in the string at which to begin searching. Defaults to 0.
### Returns
- **Boolean** - true if the string starts with the searchString, otherwise false.
### Exceptions
- **TypeError** - Thrown if searchString is a RegExp.
### Algorithm Steps
1. Let thisValue be the this value.
2. Perform ? RequireObjectCoercible(thisValue).
3. Let string be ? ToString(thisValue).
4. Let isRegexp be ? IsRegExp(searchString).
5. If isRegexp is true, throw a TypeError exception.
6. Set searchString to ? ToString(searchString).
7. Let length be the length of string.
8. Let start be the result of clamping ? ToIntegerOrInfinity(position) between 0 and length.
9. Assert: If position is undefined, then start is 0.
10. Let searchLength be the length of searchString.
11. If searchLength = 0, return true.
12. Let end be start + searchLength.
13. If end > length, return false.
14. Let substring be the substring of string from start to end.
15. If substring is searchString, return true.
16. Return false.
### Notes
- Throwing 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.
- 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.
```
--------------------------------
### Cyclic structure example for JSON.stringify
Source: https://tc39.es/ecma262/multipage/structured-data.html
Shows a value that cannot be stringified because it is cyclic. The call to JSON.stringify(a) must throw a TypeError.
```javascript
a = [];
a[0] = a;
my_text = JSON.stringify(a); // This must throw a TypeError.
```
--------------------------------
### %TypedArray%.prototype.fill(value, start, end)
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Fills all elements of the typed array from a start index to an end index with a static value. The method validates the typed array, converts the value to the appropriate numeric type, and sets each element in the range.
```APIDOC
## %TypedArray%.prototype.fill(value, start, end)
### Description
Fills all elements of the typed array from a start index to an end index with a static value. The method validates the typed array, converts the value to the appropriate numeric type, and sets each element in the range.
### Method
fill
### Endpoint
%TypedArray%.prototype.fill(value, start, end)
### Parameters
- **value** (any) - Required - The value to fill the typed array with. Converted to the element type of the typed array.
- **start** (number) - Optional - The index to start filling from. Defaults to 0.
- **end** (number) - Optional - The index to stop filling (exclusive). Defaults to the length of the typed array.
### Return Value
The typed array object (`obj`).
### Algorithm Steps
1. Let obj be the this value.
2. Let taRecord be ? ValidateTypedArray(obj, seq-cst).
3. Let length be TypedArrayLength(taRecord).
4. If obj.[[ContentType]] is bigint, set value to ? ToBigInt(value).
5. Else, set value to ? ToNumber(value).
6. Let startIndex be ? ToClampedIndex(start, length).
7. If end is undefined, let endIndex be length; else let endIndex be ? ToClampedIndex(end, length).
8. Set taRecord to ? ValidateTypedArrayBounds(obj, seq-cst).
9. Set length to TypedArrayLength(taRecord).
10. Set endIndex to min(endIndex, length).
11. Let k be startIndex.
12. Repeat, while k < endIndex,
a. Perform ! TypedArraySetElement(obj, 𝔽(k), value).
b. Set k to k + 1.
13. Return obj.
```
--------------------------------
### Dynamic import in a browser button onclick
Source: https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html
HTML button that triggers a dynamic import() when clicked. Used as an example of when the referrer can be a Realm Record, because there is no active script or module at the time the import() expression runs.
```html
```
--------------------------------
### %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Determines whether a typed array includes a certain element, returning true or false as appropriate. The search starts at fromIndex if provided; otherwise, it starts at the beginning. Uses SameValueZero comparison.
```APIDOC
## %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
### Description
Determines whether a typed array includes a certain element, returning true or false as appropriate. The search starts at fromIndex if provided; otherwise, it starts at the beginning. Uses SameValueZero comparison.
### Method
includes
### Parameters
- **searchElement** (Any) - Required - The element to search for.
- **fromIndex** (Number) - Optional - The index to start the search from. If negative, it is treated as length + fromIndex. If omitted, the search starts from index 0.
### Returns
- **Boolean** - Returns true if the element is found, otherwise false.
### Remarks
This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
### Algorithm Steps
1. Let obj be the this value.
2. Let taRecord be ? ValidateTypedArray(obj, seq-cst).
3. Let length be TypedArrayLength(taRecord).
4. If length = 0, return false.
5. Let k be ? ToClampedIndex(fromIndex, length).
6. Repeat, while k < length,
a. Let elementK be TypedArrayGetElement(obj, 𝔽(k)).
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Set k to k + 1.
7. Return false.
```
--------------------------------
### %TypedArray%.prototype.subarray ( start, end )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Returns a new TypedArray referencing a sub-interval of the original TypedArray's buffer. The new TypedArray has the same element type and uses the same ArrayBuffer, with elements from start (inclusive) to end (exclusive). Negative indices are treated as offsets from the end of the array.
```APIDOC
## %TypedArray%.prototype.subarray ( start, end )
### Description
Returns a new TypedArray whose element type is the element type of this TypedArray and whose ArrayBuffer is the ArrayBuffer of this TypedArray, referencing the elements in the interval from start (inclusive) to end (exclusive). If either start or end is negative, it refers to an index from the end of the array.
### Method
subarray
### Parameters
- **start** (number) - Required - The starting index (inclusive). Negative values count from the end.
- **end** (number) - Optional - The ending index (exclusive). Negative values count from the end. If omitted, the subarray extends to the end of the original array.
### Return Value
A new TypedArray with the same element type and underlying ArrayBuffer, referencing the specified interval.
### Remarks
This method is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
### Algorithm Steps
1. Let obj be the this value.
2. Perform ? RequireInternalSlot(obj, [[TypedArrayName]]).
3. Assert: obj has a [[ViewedArrayBuffer]] internal slot.
4. Let buffer be obj.[[ViewedArrayBuffer]].
5. Let sourceRecord be MakeTypedArrayWithBufferWitnessRecord(obj, seq-cst).
6. If IsTypedArrayOutOfBounds(sourceRecord) is true, let sourceLength be 0; else let sourceLength be TypedArrayLength(sourceRecord).
7. Let startIndex be ? ToClampedIndex(start, sourceLength).
8. Let elementSize be TypedArrayElementSize(obj).
9. Let sourceByteOffset be obj.[[ByteOffset]].
10. Let beginByteOffset be sourceByteOffset + (startIndex × elementSize).
11. If obj.[[ArrayLength]] is auto and end is undefined, return ? TypedArraySpeciesCreate(obj, « buffer, 𝔽(beginByteOffset) »).
12. If end is undefined, let endIndex be sourceLength; else let endIndex be ? ToClampedIndex(end, sourceLength).
13. Let newLength be max(endIndex - startIndex, 0).
14. Return ? TypedArraySpeciesCreate(obj, « buffer, 𝔽(beginByteOffset), 𝔽(newLength) »).
```
--------------------------------
### Capture clearing example: /(z)((a+)?(b+)?(c))*/.exec("zaacbbbcac")
Source: https://tc39.es/ecma262/multipage/text-processing.html
Shows how RepeatMatcher clears captures each iteration, returning ["zaacbbbcac", "z", "ac", "a", undefined, "c"].
```javascript
/(z)((a+)?(b+)?(c))*/.exec("zaacbbbcac")
```
--------------------------------
### Canonical equivalence comparisons with localeCompare
Source: https://tc39.es/ecma262/multipage/text-processing.html
These comparisons must all return +0𝔽 because the strings are canonically equivalent according to the Unicode Standard. The example includes pairs like ANGSTROM SIGN vs. A + COMBINING RING ABOVE, and HANGUL syllables.
```javascript
// Å ANGSTROM SIGN vs.
// Å LATIN CAPITAL LETTER A + COMBINING RING ABOVE
"\u212B".localeCompare("A\u030A")
// Ω OHM SIGN vs.
// Ω GREEK CAPITAL LETTER OMEGA
"\u2126".localeCompare("\u03A9")
// ṩ LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE vs.
// ṩ LATIN SMALL LETTER S + COMBINING DOT ABOVE + COMBINING DOT BELOW
"\u1E69".localeCompare("s\u0307\u0323")
// ḍ̇ LATIN SMALL LETTER D WITH DOT ABOVE + COMBINING DOT BELOW vs.
// ḍ̇ LATIN SMALL LETTER D WITH DOT BELOW + COMBINING DOT ABOVE
"\u1E0B\u0323".localeCompare("\u1E0D\u0307")
// 가 HANGUL CHOSEONG KIYEOK + HANGUL JUNGSEONG A vs.
// 가 HANGUL SYLLABLE GA
"\u1100\u1161".localeCompare("\uAC00")
```
--------------------------------
### get DataView.prototype.byteOffset
Source: https://tc39.es/ecma262/multipage/structured-data.html
Accessor property that returns the byte offset of the DataView from the start of its ArrayBuffer. Throws a TypeError if the DataView is out of bounds.
```APIDOC
## GET DataView.prototype.byteOffset
### Description
Returns the byte offset of the DataView from the start of its ArrayBuffer. Throws a TypeError if the DataView is out of bounds.
### Method
GET
### Endpoint
DataView.prototype.byteOffset
### Parameters
None.
### Response
#### Success Response (200)
- **byteOffset** (Number) - The byte offset of the DataView.
#### Response Example
```json
{
"byteOffset": 0
}
```
#### Error Response (TypeError)
Throws a TypeError if the DataView is out of bounds.
```
--------------------------------
### Array.prototype.indexOf ( searchElement [ , fromIndex ] )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Returns the first index at which searchElement is found using strict equality, or -1 if not found. The optional fromIndex parameter controls the starting search position.
```APIDOC
## Array.prototype.indexOf ( searchElement [ , fromIndex ] )
### Description
Compares searchElement to the elements of the array in ascending order using the IsStrictlyEqual algorithm. Returns the smallest index where searchElement is found, or -1 if not found.
### Method
indexOf
### Parameters
- **searchElement** (any) - Required - The element to locate in the array.
- **fromIndex** (number) - Optional - The index to start the search at. Defaults to +0 (whole array). If greater than or equal to the array length, -1 is returned. If negative, it is used as an offset from the end of the array.
### Return Value
- Returns the smallest index at which searchElement is found, or -1 if not found.
### Behavior
- Converts this value to an object.
- Gets the length of the array-like object.
- If length is 0, returns -1.
- Clamps fromIndex to a valid index.
- Iterates from the starting index to the end, checking each element with strict equality.
- Returns the first matching index or -1.
### Notes
- This method is intentionally generic; it does not require that its this value be an Array.
```
--------------------------------
### Uint8Array.prototype.toBase64 ( [ options ] )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Documentation for the Uint8Array.prototype.toBase64 method.
```APIDOC
## Uint8Array.prototype.toBase64 ( [ options ] )
### Description
Encodes the contents of the Uint8Array to a base64 or base64url string. Options allow selecting the alphabet and whether to omit padding.
### Method
N/A (JavaScript method)
### Endpoint
N/A
### Parameters
#### Options Object
- **alphabet** (String) - Optional - The alphabet to use: "base64" (default) or "base64url".
- **omitPadding** (Boolean) - Optional - If true, padding is omitted from the output.
### Request Example
```js
const uint8 = new Uint8Array([0xde, 0xad, 0xbe, 0xef]);
const base64 = uint8.toBase64();
const base64url = uint8.toBase64({ alphabet: "base64url", omitPadding: true });
```
### Response
#### Success Response
- Returns a String containing the base64 or base64url encoded representation.
#### Response Example
```js
"3q2+7w=="
```
### Errors
- Throws a TypeError if `alphabet` is not "base64" or "base64url".
```
--------------------------------
### Array.prototype.unshift(...items)
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Prepends the given items to the start of the array, shifting existing elements to higher indices. Returns the new length of the array. This method is generic and can be applied to any object.
```APIDOC
## Array.prototype.unshift ( ...items )
### Description
Prepends the given items to the start of the array, shifting existing elements to higher indices. Returns the new length of the array. This method is generic and can be applied to any object.
### Method
- (none)
### Endpoint
- (none)
### Parameters
- **items** (any) - Optional - The elements to prepend to the array.
### Request Example
- (none)
### Response
- (none)
### Notes
- The "length" property of this method is 1𝔽.
- This method is intentionally generic; it does not require that its this value be an Array. Therefore it can be transferred to other kinds of objects for use as a method.
```
--------------------------------
### Array.prototype.toSpliced(start, skipCount, ...items)
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Returns a new array with elements removed and/or replaced at a specified index. The original array is not modified.
```APIDOC
## Array.prototype.toSpliced(start, skipCount, ...items)
### Description
Returns a new array with elements removed and/or replaced at a specified index. The original array is not modified.
### Method
N/A (JavaScript method)
### Endpoint
N/A
### Parameters
- **start** (number) - Required - The index at which to start changing the array. Negative values are clamped to 0.
- **skipCount** (number) - Optional - The number of elements to remove starting at `start`. If omitted, all elements from `start` to the end are removed.
- **...items** (any) - Optional - The elements to add to the array, beginning at `start`.
### Request Example
N/A
### Response
#### Success Response
Returns a new array with the specified elements removed and/or replaced.
#### Response Example
```js
const arr = [1, 2, 3, 4, 5];
const spliced = arr.toSpliced(1, 2, 'a', 'b'); // [1, 'a', 'b', 4, 5]
```
```
--------------------------------
### get %TypedArray%.prototype.length
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Accessor property that returns the length of the typed array. The set accessor is undefined. This getter is not generic and requires a TypedArray this value.
```APIDOC
## get %TypedArray%.prototype.length
### Description
Accessor property that returns the length of the typed array. The set accessor is undefined. This getter is not generic and requires a TypedArray this value.
### Method
length (getter)
### Parameters
None.
### Returns
Returns the length of the typed array as a Number. If the typed array is out of bounds, returns +0.
### Algorithm Steps
1. Let obj be the this value.
2. Perform ? RequireInternalSlot(obj, [[TypedArrayName]]).
3. Assert: obj has [[ViewedArrayBuffer]] and [[ArrayLength]] internal slots.
4. Let taRecord be MakeTypedArrayWithBufferWitnessRecord(obj, seq-cst).
5. If IsTypedArrayOutOfBounds(taRecord) is true, return +0𝔽.
6. Let length be TypedArrayLength(taRecord).
7. Return 𝔽(length).
### Notes
This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot.
```
--------------------------------
### String.prototype.trimStart()
Source: https://tc39.es/ecma262/multipage/text-processing.html
Removes whitespace from the beginning of a string. This method is generic and can be transferred to other objects.
```APIDOC
## String.prototype.trimStart ( )
### Description
This method interprets a String value as a sequence of UTF-16 encoded code points and removes whitespace from the start of the string. It is intentionally generic and does not require its this value to be a String object.
### Method
- (none specified)
### Endpoint
- (not applicable)
### Parameters
- (none)
### Request Example
- (not applicable)
### Response
#### Success Response
- Returns a new String with leading whitespace removed.
#### Response Example
- (not provided)
```
--------------------------------
### String.prototype.slice ( start, end )
Source: https://tc39.es/ecma262/multipage/text-processing.html
Returns a substring of the string, starting from index start and ending before index end. Handles negative indices by counting from the end of the string.
```APIDOC
## String.prototype.slice ( start, end )
### Description
Returns a substring of the string, starting from index start and ending before index end. If end is undefined, the substring extends to the end of the string. Negative indices are treated as sourceLength + index.
### Method
slice
### Parameters
- **start** (Number) - Required - The starting index. Negative values are treated as sourceLength + start.
- **end** (Number) - Optional - The ending index (exclusive). Negative values are treated as sourceLength + end. If undefined, the substring extends to the end.
### Return Value
- **String** - The extracted substring.
### Behavior
1. Converts the this value to a string.
2. Computes the length of the string.
3. Clamps start and end to valid indices.
4. If start >= end, returns an empty string.
5. Returns the substring from start to end.
### Note
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.
```
--------------------------------
### SharedArrayBuffer.prototype.slice ( start, end )
Source: https://tc39.es/ecma262/multipage/structured-data.html
Creates a new SharedArrayBuffer containing the bytes from the original buffer between the start and end indices. Throws a TypeError if the this value is not a SharedArrayBuffer.
```APIDOC
## SharedArrayBuffer.prototype.slice ( start, end )
### Description
Creates a new SharedArrayBuffer containing the bytes from the original buffer between the start and end indices. Throws a TypeError if the this value is not a SharedArrayBuffer.
### Method
GET
### Endpoint
SharedArrayBuffer.prototype.slice
### Parameters
#### This Value
- **obj** (Object) - Required - The this value, must be a SharedArrayBuffer.
#### Arguments
- **start** (number) - Required - The starting index for the slice.
- **end** (number) - Optional - The ending index for the slice. If undefined, the length of the buffer is used.
### Response
#### Success Response (200)
- **result** (SharedArrayBuffer) - A new SharedArrayBuffer containing the sliced bytes.
#### Error Response
- **TypeError** - If the this value is not a SharedArrayBuffer, or if the new buffer is not a SharedArrayBuffer, or if the new buffer's byte length is less than the requested length.
```
--------------------------------
### Array.prototype.lastIndexOf(searchElement[, fromIndex])
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Searches the array in descending order and returns the largest index where the searchElement is found, or -1 if not found. The optional fromIndex parameter specifies the starting index for the search.
```APIDOC
## Array.prototype.lastIndexOf(searchElement[, fromIndex])
### Description
Compares searchElement to the elements of the array in descending order using the IsStrictlyEqual algorithm, and if found at one or more indices, returns the largest such index; otherwise, it returns -1𝔽. The optional second argument fromIndex defaults to the array's length minus one (i.e. the whole array is searched). If it is greater than or equal to the length of the array, the whole array will be searched. If it is less than -0𝔽, it is used to compute an offset from the end of the array. If the computed index is less than -0𝔽, -1𝔽 is returned.
### Method
lastIndexOf
### Endpoint
Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
### Parameters
#### Arguments
- **searchElement** (any) - Required - The element to locate in the array.
- **fromIndex** (number) - Optional - The index at which to start searching backwards. Defaults to the array's length minus one. If greater than or equal to the length, the whole array is searched. If negative, it is used as an offset from the end of the array.
### Return Value
The largest index at which searchElement is found, or -1𝔽 if not found.
### Algorithm
1. Let obj be ? ToObject(this value).
2. Let length be ? LengthOfArrayLike(obj).
3. If length = 0, return -1𝔽.
4. If fromIndex is not present, let k be length - 1; else let k be min(? ToAbsoluteIndex(fromIndex, length), length - 1).
5. Repeat, while k ≥ 0,
a. Let propertyKey be ! ToString(𝔽(k)).
b. Let kPresent be ? HasProperty(obj, propertyKey).
c. If kPresent is true, then
i. Let elementK be ? Get(obj, propertyKey).
ii. If IsStrictlyEqual(searchElement, elementK) is true, return 𝔽(k).
d. Set k to k - 1.
6. Return -1𝔽.
### Note
This method is intentionally generic; it does not require that its this value be an Array. Therefore it can be transferred to other kinds of objects for use as a method.
```
--------------------------------
### String.prototype.constructor
Source: https://tc39.es/ecma262/multipage/text-processing.html
The initial value of String.prototype.constructor is %String%.
```APIDOC
## String.prototype.constructor
### Description
The initial value of `String.prototype.constructor` is `%String%`.
```
--------------------------------
### String.prototype.trimLeft()
Source: https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html
Alias for String.prototype.trimStart, provided for compatibility with old code. The trimStart property is preferred.
```APIDOC
## String.prototype.trimLeft()
### Description
Alias for `String.prototype.trimStart`, provided for compatibility with old code. The `trimStart` property is preferred.
### Method
String.prototype.trimLeft()
### Parameters
None.
### Return Value
A new string with whitespace removed from the beginning of the original string.
### Note
The initial value of the `trimLeft` property is `%String.prototype.trimStart%`.
```
--------------------------------
### DataView.prototype.constructor
Source: https://tc39.es/ecma262/multipage/structured-data.html
The initial value of DataView.prototype.constructor is %DataView%.
```APIDOC
## DataView.prototype.constructor
### Description
The initial value of DataView.prototype.constructor is %DataView%.
### Method
GET
### Endpoint
DataView.prototype.constructor
### Parameters
None.
### Response
#### Success Response (200)
- **constructor** (Function) - The DataView constructor.
#### Response Example
```json
{
"constructor": "%DataView%"
}
```
```
--------------------------------
### DisposableStack.prototype.move()
Source: https://tc39.es/ecma262/multipage/control-abstraction-objects.html
Creates a new DisposableStack and transfers the resources from the current stack to it, then disposes the current stack.
```APIDOC
## DisposableStack.prototype.move()
### Description
Creates a new DisposableStack and transfers the resources from the current stack to it, then disposes the current stack.
### Method
move
### Parameters
None.
### Returns
A new DisposableStack containing the resources that were in the original stack.
### Throws
- **ReferenceError** - If the stack is already disposed.
```
--------------------------------
### ECMAScript example of missing binding in SetMutableBinding
Source: https://tc39.es/ecma262/multipage/executable-code-and-execution-contexts.html
This example demonstrates a scenario where SetMutableBinding encounters a missing binding (step 1). The code uses eval and the delete operator to create a situation where the binding for 'x' is deleted before assignment, causing the algorithm to handle a missing binding.
```javascript
function f() { eval("var x; x = (delete x, 0);"); }
```
--------------------------------
### Uint8Array.prototype.setFromHex ( string )
Source: https://tc39.es/ecma262/multipage/indexed-collections.html
Documentation for the Uint8Array.prototype.setFromHex method.
```APIDOC
## Uint8Array.prototype.setFromHex ( string )
### Description
Sets the contents of the Uint8Array to the bytes decoded from a hexadecimal string. Returns an object with the number of bytes read and written, or throws an error if the string is invalid.
### Method
N/A (JavaScript method)
### Endpoint
N/A
### Parameters
- **string** (String) - Required - The hexadecimal string to decode.
### Request Example
```js
const uint8 = new Uint8Array(4);
const result = uint8.setFromHex("deadbeef");
```
### Response
#### Success Response
- **read** (Number) - The number of hexadecimal characters read.
- **written** (Number) - The number of bytes written.
#### Response Example
```js
{ read: 8, written: 4 }
```
### Errors
- Throws a TypeError if `string` is not a String.
- Throws the error from the decoding process if the string is invalid.
```
--------------------------------
### Set.prototype.constructor
Source: https://tc39.es/ecma262/multipage/keyed-collections.html
The initial value of Set.prototype.constructor is %Set%.
```APIDOC
## Set.prototype.constructor
### Description
The initial value of Set.prototype.constructor is %Set%.
```
--------------------------------
### String.prototype.padEnd ( maxLength [ , fillString ] )
Source: https://tc39.es/ecma262/multipage/text-processing.html
Documentation for the String.prototype.padEnd method, which pads the end of a string to a specified length.
```APIDOC
## String.prototype.padEnd ( maxLength [ , fillString ] )
### Description
Pads the current string with the given fill string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end (right side) of the string.
### Method
padEnd
### Parameters
- **maxLength** (Number) - Required - The target length of the resulting string.
- **fillString** (String) - Optional - The string to pad with. Defaults to a space (U+0020) if undefined.
### Return Value
- **String** - The padded string.
### Example
```js
"abc".padEnd(10); // "abc "
"abc".padEnd(10, "foo"); // "abcfoofoof"
```
```
--------------------------------
### Object.getOwnPropertyNames ( obj )
Source: https://tc39.es/ecma262/multipage/fundamental-objects.html
Gets the names (string keys) of all own properties of an object.
```APIDOC
## Object.getOwnPropertyNames ( obj )
### Description
Returns an array of all own property names (as strings) of the given object.
### Method
CALL
### Endpoint
Object.getOwnPropertyNames
### Parameters
- **obj** (Object) - Required - The object to inspect.
### Response
Returns an array of strings representing the object's own property names.
```
--------------------------------
### Object.getOwnPropertyDescriptors ( obj )
Source: https://tc39.es/ecma262/multipage/fundamental-objects.html
Gets all own property descriptors of an object as a single object.
```APIDOC
## Object.getOwnPropertyDescriptors ( obj )
### Description
Returns an object containing all own property descriptors of the given object.
### Method
CALL
### Endpoint
Object.getOwnPropertyDescriptors
### Parameters
- **obj** (Object) - Required - The object to inspect.
### Response
Returns a new object with own property keys and their property descriptors as own properties.
```
--------------------------------
### get Set.prototype.size
Source: https://tc39.es/ecma262/multipage/keyed-collections.html
Returns the number of elements in the Set. This is an accessor property with no setter.
```APIDOC
## get Set.prototype.size
### Description
Returns the number of elements in the Set. This is an accessor property with no setter.
### Method
get size
### Returns
- **number** - The number of elements in the Set.
### Behavior
- Throws a TypeError if the this value does not have a [[SetData]] internal slot.
```
--------------------------------
### Negative lookahead example with backreferences
Source: https://tc39.es/ecma262/multipage/text-processing.html
Example regex using negative lookahead (?!(a+)b\2c) to find an 'a' not followed by a specific pattern. The second \2 outside the lookahead matches undefined and always succeeds. The result is the array ["baaabaac", "ba", undefined, "abaac"].
```javascript
/(.*?)a(?!(a+)b\2c)\2(.*)/.exec("baaabaac")
```
```javascript
["baaabaac", "ba", undefined, "abaac"]
```
--------------------------------
### DataView ( buffer [ , byteOffset [ , byteLength ] ] )
Source: https://tc39.es/ecma262/multipage/structured-data.html
Creates and initializes a new DataView object when called as a constructor. Throws a TypeError if called as a function. The constructor validates the buffer and offset, and sets up the internal state for the new DataView.
```APIDOC
## DataView ( buffer [ , byteOffset [ , byteLength ] ] )
### Description
Creates and initializes a new DataView object when called as a constructor. Throws a TypeError if called as a function. The constructor validates the buffer and offset, and sets up the internal state for the new DataView.
### Method
Constructor
### Endpoint
DataView ( buffer [ , byteOffset [ , byteLength ] ] )
### Parameters
#### Arguments
- **buffer** (ArrayBuffer) - Required - The ArrayBuffer to view.
- **byteOffset** (Number) - Optional - The byte offset into the buffer. Defaults to 0.
- **byteLength** (Number) - Optional - The number of bytes to view. Defaults to the remaining buffer length.
### Behavior
- If called as a function (NewTarget is undefined), throws a TypeError.
- If buffer does not have an [[ArrayBufferData]] internal slot, throws a TypeError.
- If byteOffset is not a valid index, throws a RangeError.
- If buffer is detached, throws a TypeError.
- If offset is greater than the buffer byte length, throws a RangeError.
- If byteLength is provided and offset + byteLength exceeds the buffer length, throws a RangeError.
### Return Value
- A new DataView object with the specified buffer, byte offset, and byte length.
```
--------------------------------
### get Map.prototype.size
Source: https://tc39.es/ecma262/multipage/keyed-collections.html
An accessor property that returns the number of entries in the Map. The set accessor is undefined.
```APIDOC
## get Map.prototype.size
### Description
Returns the number of entries in the Map. The set accessor is undefined.
### Method
`get size`
### Parameters
None.
### Returns
- (Number) - The number of entries in the Map.
### Algorithm
1. Let `map` be the `this` value.
2. Perform ? RequireInternalSlot(map, [[MapData]]).
3. Let `count` be 0.
4. For each Record { [[Key]], [[Value]] } entry of map.[[MapData]], do
a. If entry.[[Key]] is not empty, set `count` to `count + 1`.
5. Return 𝔽(count).
```
--------------------------------
### AsyncDisposableStack.prototype.move()
Source: https://tc39.es/ecma262/multipage/control-abstraction-objects.html
Creates a new AsyncDisposableStack and transfers the current stack's resources to it, then marks the current stack as disposed.
```APIDOC
## AsyncDisposableStack.prototype.move()
### Description
Creates a new AsyncDisposableStack and transfers the current stack's resources to it, then marks the current stack as disposed.
### Method
move
### Endpoint
AsyncDisposableStack.prototype.move()
### Parameters
None.
### Returns
A new AsyncDisposableStack containing the resources previously held by the original stack.
### Throws
- **ReferenceError** - If the stack is already disposed.
### Example
```js
const stack = new AsyncDisposableStack();
const newStack = stack.move();
```
```
--------------------------------
### get RegExp.prototype.source
Source: https://tc39.es/ecma262/multipage/text-processing.html
Accessor property that returns the source text of the regular expression pattern. The set accessor is undefined.
```APIDOC
## get RegExp.prototype.source
### Description
Accessor property that returns the source text of the regular expression pattern. The set accessor is undefined.
### Returns
- **String** - The source text of the regular expression pattern.
### Exceptions
- **TypeError** - If the this value is not an Object, or if the object does not have an [[OriginalSource]] internal slot and is not %RegExp.prototype%.
```
--------------------------------
### String.prototype.bold()
Source: https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html
Wraps the string in a HTML tag. This is a legacy method for web browser compatibility.
```APIDOC
## String.prototype.bold()
### Description
Wraps the string in a HTML tag. This is a legacy method for web browser compatibility.
### Method
String.prototype.bold()
### Syntax
bold()
### Parameters
None.
### Return Value
A string containing the original string wrapped in tags.
### Example
```js
"Hello".bold(); // "Hello"
```
```