Set.prototype.keys() — a set value iterator
Set.prototype.keys() returns a new iterator over a set's values in insertion order. It returns neither indexes nor an array: in a Set, keys and values refer to the same elements.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Set.prototype.keys() returns a new iterator over a set's values in insertion order. It returns neither indexes nor an array: in a Set, keys and values refer to the same elements.
The size property reports the current number of distinct values in a Set. Read it as set.size, without parentheses. An empty set has size 0, and adding the same value again does not increase its size.
If the input elements remain unchanged during the call, symmetricDifference() returns a new Set containing values present in exactly one of the two sets. The method itself does not modify the input sets.
Set.prototype.union(other) creates a new Set containing values from both sets without duplicates. It preserves the left set's order, then appends new values from other. The argument must support the set-like object protocol, not merely iteration.
The values() method returns a new iterator over a Set's values in insertion order. It does not create an array or copy the set; reading advances the iterator, and changes to the set can affect the remaining traversal.
SharedArrayBuffer holds bytes that different JavaScript agents can access. Views interpret those bytes, while Atomics helps coordinate concurrent operations.
String.fromCharCode creates a string from supplied UTF-16 code units. It does not interpret arguments as complete Unicode code points: characters outside the Basic Multilingual Plane require a surrogate pair.
String.fromCodePoint creates a string from Unicode code points, including values above 0xFFFF. It automatically encodes them as UTF-16; invalid numeric values cause RangeError.
A string's length property returns its number of UTF-16 code units, which is not always its number of user-perceived characters. Read it as text.length, without parentheses.
String.prototype.at(index) returns a string containing one UTF-16 code unit. Negative indices count from the end, and an out-of-range position returns undefined.
The charAt() method returns a string containing one UTF-16 code unit at a zero-based index, or an empty string outside the valid range. It does not guarantee a complete Unicode character.
The charCodeAt method returns the numeric value of the UTF-16 code unit at an index, or NaN outside the string. It does not always return a complete Unicode code point.
The codePointAt(pos) method returns the numeric value of the code point starting at a specified UTF-16 index. It recognizes surrogate pairs, but the index still identifies a code unit, not the next character visible on screen.
String.prototype.concat appends any number of arguments to a string, converting them to text. It returns a primitive string value and leaves the original string unchanged.
String.prototype.endsWith checks whether a string ends with specified text and returns true or false. It is case-sensitive, leaves the string unchanged, and lets you specify an earlier end boundary for the check.
String.prototype.includes checks whether text contains a given substring and returns true or false. It is case-sensitive, supports a starting position, and does not accept ordinary regular expressions.
String.prototype.indexOf returns the index of the first substring match at or after the starting point obtained by converting and clamping position, or -1 if there is no match. It is case-sensitive and measures indices in UTF-16 code units.
lastIndexOf() returns the index of the last substring occurrence or -1. The optional position limits where a match starts, not where it ends.
String.prototype.localeCompare compares two strings using linguistic ordering rules. The sign of its result determines their order; locales and options customize comparison in environments supporting ECMA-402.
The match() method finds regular expression matches in a string. The g flag changes the result shape: without it you get at most one match with capturing groups; with it you get an array of full matches. No match produces null.
String.prototype.matchAll returns an iterator over regular-expression matches, including capture groups and positions. For an ordinary RegExp it requires the g flag and leaves the original pattern's lastIndex unchanged.
normalize() returns text in a selected Unicode normalization form. It helps compare equivalent character representations and supports NFC, NFD, NFKC, and NFKD, defaulting to NFC.
String.prototype.padEnd pads the end of a string to a target length by repeating a supplied string or default spaces. It leaves the original unchanged and never shortens a string that is already long enough.
String.prototype.padStart pads the beginning of a string to a specified length by repeating and, when necessary, truncating the padding. It leaves the original unchanged and never shortens a string that is already long enough. Length is measured in UTF-16 code units.