JavaScript Map

0
11K

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.

Cerca
Categorie
Leggi tutto
Искусство, культура и развлечения
Амадей. Amadeus. (1984)
1781 год. Антонио Сальери успешно справляется с обязанностями придворного композитора при...
By Nikolai Pokryshkin 2022-12-27 17:57:07 0 38K
Marketing and Advertising
Common Mistakes and Pitfalls in Market Research (and How to Avoid Them)
Introduction: Why Good Research Still Fails Even the most ambitious marketing teams and...
By Dacey Rankins 2025-10-10 20:08:59 0 3K
Marketing and Advertising
How Do I Reach an Audience That Doesn’t Know It Needs My Content?
Turning the Unaware Into Engaged, Loyal Customers Through Smart Content Marketing One of the...
By Dacey Rankins 2025-09-30 15:56:20 0 3K
Marketing and Advertising
Expanding Your Digital Strategy: Deep Dive into Multi-Channel Web Marketing and YouTube Optimization
1. Building a Multi-Channel Framework Modern web marketing is no longer about mastering one...
By Dacey Rankins 2025-11-13 17:09:01 0 4K
Marketing and Advertising
How Long Does It Take for PR Efforts to Show Results?
Understanding PR Timelines, Momentum, and Sustainable Reputation Growth Public Relations (PR) is...
By Dacey Rankins 2025-10-30 16:11:59 0 4K

BigMoney.VIP Powered by Hosting Pokrov