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
What is the Scope of Commerce?
What is the Scope of Commerce? Commerce is one of the most important parts of modern economic...
By Leonard Pokrovski 2026-02-17 18:33:02 0 3K
Human Resources
What Are Examples of Outsourcing?
Outsourcing is widely used across industries and business functions. To better understand how it...
By Dacey Rankins 2026-04-02 18:53:27 0 2K
Business
What Are the Key Functions of Management?
In the dynamic world of business and organizations, effective management is essential for...
By Dacey Rankins 2025-05-12 16:30:28 0 7K
Marketing and Advertising
How Do I Exclude Converters from Retargeting? A Complete Guide to Smarter Targeting and Better ROI
One of the fastest ways to waste retargeting budget is continuing to show ads to people who have...
By Dacey Rankins 2026-02-16 14:44:02 0 6K
Personal Finance
How Can I Improve My Credit Score?
How Can I Improve My Credit Score? Your credit score plays a crucial role in your financial...
By Leonard Pokrovski 2025-10-27 21:07:22 0 13K

BigMoney.VIP Powered by Hosting Pokrov