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.

Search
Categories
Read More
Business
How Can I Align Individual Purpose with Team Objectives?
In today’s dynamic workplace, aligning individual purpose with team objectives is not just...
By Dacey Rankins 2025-07-17 14:25:54 0 14K
Business
What Is Sales Operations (SalesOps)?
Sales operations, often called SalesOps, is one of the most misunderstood — and most...
By Dacey Rankins 2025-12-23 20:02:19 0 6K
Economics
How does inflation affect income inequality?
How Does Inflation Affect Income Inequality? Inflation is a sustained increase in the general...
By Leonard Pokrovski 2026-07-05 02:04:04 0 2K
Sport
Sisters on Track (2021)
A coming of age story about hope, belonging, and the metaphorical and literal sisterhood of young...
By Leonard Pokrovski 2022-09-02 18:21:53 0 33K
Decision Making and Problem Solving
What is present bias in economics?
What Is Present Bias in Economics? The Tyranny of Now A curious feature of human nature reveals...
By Michael Pokrovski 2026-06-10 11:54:58 0 2K

BigMoney.VIP Powered by Hosting Pokrov




google-site-verification=q_0zhvNWwTfwbQ-uEJsvcmUKKbtOWUTgl3H57qDiFrg