JavaScript Map

0
11KB

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.

Suche
Kategorien
Mehr lesen
Social Issues
John Wick: Chapter 4. (2023)
John Wick uncovers a path to defeating The High Table. But before he can earn his freedom, Wick...
Von Leonard Pokrovski 2023-03-30 19:36:31 0 28KB
Social Issues
The Godfather. (1972)
The Godfather "Don" Vito Corleone is the head of the Corleone mafia family in New York. He is at...
Von Leonard Pokrovski 2022-10-31 19:32:39 0 28KB
Business
What Skills Does a Growth Hacker Need?
In today’s competitive digital landscape, businesses are constantly seeking ways to grow...
Von Dacey Rankins 2025-09-11 16:29:54 0 3KB
Спорт
Дом на глубине. The Deep House. (2021)
Видеоблогеры Тина и Бен путешествуют по миру, снимая старые заброшенные здания. Решив впечатлить...
Von Nikolai Pokryshkin 2022-09-03 20:34:06 0 37KB
Science Fiction and Fantasy
Terminator 2: Judgment Day. (1991)
A cyborg, identical to the one who failed to kill Sarah Connor, must now protect her 10-year old...
Von Leonard Pokrovski 2022-11-22 21:23:05 0 25KB

BigMoney.VIP Powered by Hosting Pokrov