JavaScript Map

0
10Кб

Map objects are collections of key-value pairs. A key in the Map may only occur once; it is unique in the Map's collection. A Map object is iterated by key-value pairs — a for...of loop returns a 2-member array of [key, value] for each iteration. Iteration happens in insertion order, which corresponds to the order in which each key-value pair was first inserted into the map by the set() method (that is, there wasn't a key with the same value already in the map when set() was called).

The specification requires maps to be implemented "that, on average, provide access times that are sublinear on the number of elements in the collection". Therefore, it could be represented internally as a hash table (with O(1) lookup), a search tree (with O(log(N)) lookup), or any other data structure, as long as the complexity is better than O(N).

Key equality

Value equality is based on the SameValueZero algorithm. (It used to use SameValue, which treated 0 and -0 as different. Check browser compatibility.) This means NaN is considered the same as NaN (even though NaN !== NaN) and all other values are considered equal according to the semantics of the === operator.

Поиск
Категории
Больше
История
Бесславные ублюдки. Inglourious Basterds. (2009)
Вторая мировая война. В оккупированной немцами Франции группа американских солдат-евреев наводит...
От Nikolai Pokryshkin 2022-12-28 11:42:21 0 28Кб
Mental Health
Scizophrenia Negative and Cognitive Symptoms
Negative symptomsNegative symptoms are deficits of normal emotional responses, or of other...
От Kelsey Rodriguez 2023-01-26 16:34:24 0 11Кб
Время
Time
Time is the continued sequence of existence and events that occurs in an apparently irreversible...
От FWhoop Xelqua 2022-09-07 13:48:10 0 31Кб
Ужасы
Чужой. Alien. (1979)
В далеком будущем возвращающийся на Землю грузовой космический корабль перехватывает исходящий с...
От Nikolai Pokryshkin 2022-12-09 13:14:12 1 31Кб
Science
Unveiling the Wonders of Science: A Journey into Discovery
Science, the systematic pursuit of knowledge through observation, experimentation, and...
От Dacey Rankins 2024-05-22 14:31:31 0 13Кб

BigMoney.VIP Powered by Hosting Pokrov