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
Business
What Is Omnichannel Retail? The Strategy Behind Seamless Customer Experiences
The customer standing in a store aisle is not just a customer standing in a store aisle. They...
By Dacey Rankins 2026-07-13 21:14:06 0 3K
Programming
Python Steam API
python-steam-api is a Python library wrapper for the web API Steam. It provides many functions...
By Jesse Thomas 2023-04-21 19:56:56 0 12K
Personal Finance
How Do I Maximize Tax Advantages Before the End of the Year?
  How Do I Maximize Tax Advantages Before the End of the Year? Every year, the period...
By Leonard Pokrovski 2025-12-27 22:31:43 0 19K
Business
How Do I Start a Speech?
Starting a speech is one of the most important parts of public speaking. Your opening sets the...
By Dacey Rankins 2025-12-10 17:43:10 0 7K
Marketing and Advertising
Is YouTube Advertising Still Effective in 2026?
With constant changes in digital marketing—privacy updates, AI-driven algorithms,...
By Dacey Rankins 2026-03-04 18:42:13 0 5K

BigMoney.VIP Powered by Hosting Pokrov