JavaScript Map

0
12K

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 Strategies Do You Use to Prioritize Tasks Effectively?
In the fast-paced world of leadership and business, effective prioritization is more than just...
By Dacey Rankins 2025-05-09 15:08:25 0 8K
Issues
100+ questions that will save you from awkward silence in online meetings
As work communication moves online, appointments and meetings become somewhat more complex. Body...
By FWhoop Xelqua 2022-10-19 12:12:02 0 41K
Economics
What Is Autocorrelation?
What Is Autocorrelation? Autocorrelation, also known as serial correlation, is a statistical...
By Leonard Pokrovski 2026-03-23 17:37:36 0 1K
Business
How Does SEO Help With Lead Generation?
SEO (Search Engine Optimization) is one of the most powerful long-term lead generation strategies...
By Dacey Rankins 2025-12-17 21:46:19 0 5K
Economics
What is Behavioral Economics?
What is Behavioral Economics? Behavioral economics is a field that blends insights from...
By Leonard Pokrovski 2026-01-31 22:36:12 0 4K

BigMoney.VIP Powered by Hosting Pokrov