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
Business and Corporate Finance
What Are the Main Sources of Business Finance?
What Are the Main Sources of Business Finance? Finance is the lifeblood of any business. Whether...
By Leonard Pokrovski 2025-12-27 22:35:36 0 7K
Economics
How Do Banks Affect the Economy?
How Do Banks Affect the Economy? The modern man believes banks store money. This is a charming...
By Leonard Pokrovski 2026-05-15 20:05:48 0 1K
Business
What Product Metrics Do You Actually Keep Track of and How Often Do You Review the Numbers?
Every successful product team knows that data is the compass guiding their decisions. Without...
By Dacey Rankins 2025-08-28 17:39:19 0 7K
Economics
What Is Economic Development?
What Is Economic Development? Economic development is a broad and multifaceted concept that...
By Leonard Pokrovski 2026-04-07 10:32:40 0 922
Business
How Can I Improve the Production Quality of My Content?
In today’s digital landscape, content creators are under pressure to produce high-quality...
By Dacey Rankins 2025-02-19 15:29:30 0 16K

BigMoney.VIP Powered by Hosting Pokrov