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
Human Resources
What Is Knowledge Sharing in Organizations?
In today’s knowledge-driven economy, the success of organizations depends not only on what...
By Dacey Rankins 2026-03-26 16:03:42 0 1K
Business
How Do Startup Founders Split Equity with Co-Founders?
Starting a business is an exciting yet challenging journey, and one of the most crucial decisions...
By Dacey Rankins 2025-04-04 14:12:41 0 16K
Virtual Reality
The Death of Virtual Reality: What VR Technologies Have in Store for the Home
Three-dimensional bummer Seven years. That's how long it has been since the incredible success...
By Dacey Rankins 2024-04-01 17:47:50 0 17K
Business and Corporate Finance
What Does Corporate Finance Do?
What Does Corporate Finance Do? Functions and Scope Within a Company Corporate finance is a...
By Leonard Pokrovski 2026-01-18 17:00:18 0 5K
Business
What Are Common Challenges in Implementing a Business Strategy?
Implementing a business strategy successfully is a fundamental goal for any organization....
By Dacey Rankins 2024-12-26 13:38:07 0 15K

BigMoney.VIP Powered by Hosting Pokrov