JavaScript Map

0
13K

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.

Pesquisar
Categorias
Leia Mais
Marketing and Advertising
Why Should I Use Video Marketing? The Strategic Benefits for Modern Businesses
Introduction Video marketing is one of the most flexible and powerful tools in a...
Por Dacey Rankins 2025-11-07 20:05:27 0 4K
Социальные проблемы
12 лет рабства. 12 Years a Slave. (2013)
Соломон Нортап был женатым и образованным мужчиной, который жил и работал в штате Нью-Йорк, когда...
Por Nikolai Pokryshkin 2023-03-21 12:18:17 0 50K
Strength Sports
Unveiling the World of Strength Sports: Power, Precision, and Passion
Unveiling the World of Strength Sports: Power, Precision, and Passion Strength sports have...
Por Leonard Pokrovski 2024-07-10 07:58:54 0 23K
Ethnicity
Understanding Ethnicity: Its Significance, Dimensions, and Impact
Ethnicity is a complex and multifaceted concept that plays a central role in shaping individuals'...
Por Dacey Rankins 2024-11-26 15:01:56 0 10K
Business
What Are the Benefits and Challenges of Remote Work?
Remote work has become increasingly popular, especially in the wake of the global pandemic. Many...
Por Dacey Rankins 2025-01-29 17:02:10 0 12K

BigMoney.VIP Powered by Hosting Pokrov