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
Decision Making and Problem Solving
How can I memorize things faster?
The mind is not a warehouse, and it is certainly not a hard drive. We operate under the...
By Michael Pokrovski 2026-07-11 13:26:33 0 790
Marketing and Advertising
What Are Common Billboard Advertising Mistakes?
Billboard advertising offers massive visibility, but visibility alone does not guarantee...
By Dacey Rankins 2026-01-15 17:36:40 0 6K
Social Issues
The Great Escape. (1963)
Allied prisoners of war plan for several hundred of their number to escape from a German camp...
By Leonard Pokrovski 2023-02-22 16:42:02 0 21K
Business
How Do You Handle Multiple Tasks Efficiently?
Handling multiple tasks efficiently is a core requirement in office administration. Office...
By Dacey Rankins 2026-04-20 17:59:06 0 4K
Finance
How Long Does It Take to Read Finance Biographies?
How Long Does It Take to Read Finance Biographies? A Look at Why They’re So Dense —...
By Leonard Pokrovski 2025-10-08 20:59:04 0 14K

BigMoney.VIP Powered by Hosting Pokrov