JavaScript Map

0
5K

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
Play-By-Mail
The World of Play-by-Mail Games: A Nostalgic and Strategic Gaming Experience
In today’s digital age, video games and online multiplayer experiences dominate the gaming...
By Dacey Rankins 2024-11-22 14:37:53 0 3K
Социальные проблемы
История Игрушек. Большой побег. Toy Story 3. (2010)
Энди почти 18 лет, ему остаётся 3 дня до отправки в колледж, в то время как его игрушки, в том...
By Nikolai Pokryshkin 2023-01-08 18:24:06 0 15K
Mental Health
Dyslexia: Causes
Researchers have been trying to find the neurobiological basis of dyslexia since the condition...
By Kelsey Rodriguez 2023-06-19 17:58:22 0 4K
Mental Health
Autism Spectrum: Features and Characteristics
Pre-diagnosisFor many autistic individuals, characteristics usually first appear during infancy...
By Kelsey Rodriguez 2023-02-14 13:30:27 0 4K
Телевидение
Первый Музыкальный канал, прямой эфир. Беларусь
«Первый музыкальный» — музыкальный телеканал из Беларуси. Телеканал транслирует...
By Nikolai Pokryshkin 2022-11-20 22:18:19 0 22K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov