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
How Can I Secure Additional Funding for Scaling?
Scaling a business is often the most exciting yet challenging stage of entrepreneurship. Unlike...
By Dacey Rankins 2025-09-05 15:41:29 0 13K
Marketing and Advertising
What Is Negative Keyword Targeting?
Negative keyword targeting is one of the most important — and most overlooked —...
By Dacey Rankins 2026-02-19 17:14:48 0 6K
Business
How Do I Handle Objections During the Closing Phase?
Handling objections effectively is one of the most critical skills in sales. Objections are not a...
By Dacey Rankins 2025-11-19 20:12:13 0 8K
Economics
What Is Commerce? (In Simple Words)
What Is Commerce? (In Simple Words) Commerce means buying and selling goods and services.In...
By Leonard Pokrovski 2026-02-19 02:27:50 0 5K
Consultants
20 ways to attract visitors to the site through your personal link!
How to attract visitors to the site through your personal link? This question is asked by almost...
By Nikolai Pokryshkin 2022-08-14 22:31:09 0 47K

BigMoney.VIP Powered by Hosting Pokrov