JavaScript Map

0
7K

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.

Buscar
Categorías
Read More
Социальные проблемы
Охота. The Hunt. (2012)
42-летний Лукас живет в небольшой датской деревушке, работает воспитателем в детском саду и...
By Nikolai Pokryshkin 2023-01-12 17:44:38 0 20K
Financial Services
Law of Demand
Key points The law of demand states that a higher price leads to a lower...
By Mark Lorenzo 2023-01-25 14:05:14 0 10K
Herramientas
Tools used to rennovate
If the Fixies really existed, they would be the most welcome guests in every home. However, they...
By FWhoop Xelqua 2023-05-14 21:08:16 0 18K
Trading Card Games
An Introduction to Trading Card Games: The Art of Collecting and Competing
Trading card games (TCGs) have captured the imaginations of millions of players around the world....
By Dacey Rankins 2024-11-28 14:52:48 0 6K
Социальные проблемы
Секреты Лос-Анджелеса. L.A. Confidential. (1997)
Бад Уайт и Эд Эксли работают в полиции Лос-Анджелеса. Они настолько разные, что порой ненавидят...
By Nikolai Pokryshkin 2023-01-29 11:40:28 0 15K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov