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
Rural Living
Life in the city and in the village: Pros and cons of the city and village
What is better than a town or village? There is no definitive answer to this question. At least,...
By FWhoop Xelqua 2023-02-02 16:26:24 0 27K
Marketing and Advertising
How Long Does It Take to Acquire Users?
Understanding the Timeline, Factors, and Strategies for Effective User Acquisition Acquiring...
By Dacey Rankins 2026-02-27 18:38:35 0 5K
Business
How Is Data Protected in the Cloud?
Few topics generate more anxiety in technology discussions than data security. Executives worry...
By Dacey Rankins 2026-06-05 03:39:31 0 5K
Contests
The Exciting World of Art Contests: Fostering Creativity and Talent
Art contests have long been a significant part of the creative landscape, providing artists of...
By Dacey Rankins 2024-12-12 14:28:33 0 12K
Business
Is Mobile Recruiting Effective?
Mobile recruiting refers to the use of smartphones, tablets, and mobile apps to attract, engage,...
By Dacey Rankins 2025-08-13 20:11:18 0 7K

BigMoney.VIP Powered by Hosting Pokrov