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.

Zoeken
Categorieën
Read More
Business
What Closing Techniques or Methods Exist?
Closing is one of the most important parts of the sales process because it transforms interest...
By Dacey Rankins 2025-11-19 19:39:16 0 8K
Human Resources
How Does Outsourcing Work?
Outsourcing is a widely used business strategy, but to truly understand its value, it’s...
By Dacey Rankins 2026-04-02 18:51:12 0 5K
Business
What Is the Difference Between the On-Demand Economy and the Gig Economy?
The terms often appear together. They headline business conferences. They dominate startup pitch...
By Dacey Rankins 2026-06-29 06:35:14 0 2K
Financial Services
Beyond GDP: other ways to measure the economy
Key points Gross national product, or GNP, includes what is produced...
By Mark Lorenzo 2023-06-06 19:49:43 0 28K
Business
How Are Potential Profits Used in a Social Enterprise?
Social enterprises are built on the idea that business can be a force for good. Unlike...
By Dacey Rankins 2025-04-15 21:23:38 0 22K

BigMoney.VIP Powered by Hosting Pokrov