JavaScript Map

0
12Кб

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.

Поиск
Категории
Больше
Financial Services
The Phillips curve in the Keynesian perspective
Key points A Phillips curve shows the tradeoff between unemployment and inflation...
От Mark Lorenzo 2023-06-21 18:14:23 0 13Кб
Financial Services
Changes in equilibrium price and quantity: the four-step process
Key points There is a four-step process that allows us to predict how an event...
От Mark Lorenzo 2023-04-10 20:19:42 0 23Кб
Business
How Do You Motivate and Inspire Your Team?
Motivating and inspiring a team is one of the most important—and often most...
От Dacey Rankins 2025-05-12 16:44:09 0 6Кб
News and Media
15 fascinating popular science channels
1. AsapSCIENCE Did the egg come before the chicken or vice versa? The authors of the...
От FWhoop Xelqua 2023-04-05 13:31:53 0 30Кб
Finance
What Are the Major and Famous Currency Pairs in Forex?
What Are the Major and Famous Currency Pairs in Forex? The foreign exchange market, or Forex, is...
От Leonard Pokrovski 2025-10-16 19:07:59 0 4Кб

BigMoney.VIP Powered by Hosting Pokrov