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
How Do I Solve the Chicken-and-Egg Problem on a Marketplace?
Few business challenges sound as innocent as the chicken-and-egg problem. The phrase itself...
By Dacey Rankins 2026-06-17 14:14:19 0 2K
Economics
How does the gig economy affect industrial relations?
How Does the Gig Economy Affect Industrial Relations? Introduction The gig economy has...
By Leonard Pokrovski 2026-07-20 23:58:09 0 418
Emulators
9 Best Android Emulators for PC and Mac
Why do I need an emulator? Android emulators allow you to run smartphone apps and games on your...
By FWhoop Xelqua 2022-10-03 16:50:33 0 38K
Finance
What are the most recent (new) finance biography books?
The finance biography genre has experienced a surge of compelling new releases in 2025, offering...
By Leonard Pokrovski 2025-10-08 19:42:14 0 10K
Business
What Is a Pitch?
Introduction: Why “Pitching” Matters Everywhere Whether you're trying to attract...
By Dacey Rankins 2025-12-02 20:07:43 0 6K

BigMoney.VIP Powered by Hosting Pokrov