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
Economics
Interest rate explained
Interest Rate Explained An interest rate is the cost of borrowing money or the return earned...
By Leonard Pokrovski 2026-08-09 19:58:58 0 2K
Visual Arts
The World of Visual Arts: A Creative Journey Through Time and Expression
Visual arts, encompassing a wide range of artistic disciplines, have been an essential part of...
By Dacey Rankins 2024-11-07 16:31:47 0 15K
Human Resources
How Does HR Ensure Labor Law Compliance?
Every organization operates within a legal framework that governs how it treats employees,...
By Dacey Rankins 2026-03-22 14:38:10 0 8K
Business
Best PaaS for Python: Choosing the Platform That Lets Developers Build, Ship, and Scale
A Python application often begins with something deceptively simple. A few lines of code. A...
By Dacey Rankins 2026-07-10 11:27:09 0 7K
Economics
What is inflation in theory?
What Is Inflation in Theory? A Price Tag That Refuses to Sit Still I remember standing in a...
By Leonard Pokrovski 2026-05-05 09:12:17 0 4K

BigMoney.VIP Powered by Hosting Pokrov