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.

Căutare
Categorii
Citeste mai mult
Productivity
How can I improve my focus?
How Can I Improve My Focus? Focus is one of the most valuable cognitive abilities in modern...
By Michael Pokrovski 2026-04-18 05:51:21 0 12K
Business
How Do Startup CEOs Manage Work-Life Balance?
In the high-octane world of startups, where agility and rapid decision-making are often the keys...
By Dacey Rankins 2025-05-05 14:45:01 0 10K
Business
What Is the Difference Between B2B and B2C? One Sells to Organizational Logic. The Other Sells to Human Emotion Under Time Pressure.
A man buying toothpaste at a pharmacy and a procurement director approving a $250,000 software...
By Dacey Rankins 2026-05-25 18:36:23 0 5K
Educaţie
Education: Empowering Minds, Shaping Futures
Education: Empowering Minds, Shaping Futures Introduction:Education is the cornerstone of human...
By Leonard Pokrovski 2024-06-06 19:38:01 0 30K
Economics
What are leading economic indicators?
What Are Leading Economic Indicators? An economy does not collapse all at once. Nor does it...
By Leonard Pokrovski 2026-05-18 20:57:01 0 5K

BigMoney.VIP Powered by Hosting Pokrov