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.

Căutare
Categorii
Citeste mai mult
Artificial Intelligence
What is AI?
It's clear about artificial intelligence (AI) Simply put, artificial intelligence (AI) is a...
By FWhoop Xelqua 2022-12-13 14:28:20 0 20K
Television
Pittsburgh Faith & Family. Live TV.
The Pittsburgh Faith & Family Channel brings the truth of the Good News directly into your...
By Nikolai Pokryshkin 2022-11-20 20:58:51 0 39K
Marketing and Advertising
What Is Content Marketing and Why Does It Matter?
Content marketing has become one of the most powerful ways for businesses to attract, engage, and...
By Dacey Rankins 2025-11-03 15:04:56 0 7K
Business
Which Pages Drive the Most Conversions?
In digital marketing, not all website pages are created equal. While every page plays a role in...
By Dacey Rankins 2025-08-28 17:58:26 0 7K
Marketing and Advertising
What Are the Main Types of SEO?
Understanding On-Page, Off-Page, Technical, and Local SEO (and How They Work Together) Search...
By Dacey Rankins 2025-10-31 15:40:23 0 6K

BigMoney.VIP Powered by Hosting Pokrov