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
Marketing and Advertising
What Is YouTube Remarketing? A Complete Guide to Reaching Viewers with Video-Based Retargeting
  Introduction Video has become one of the most influential forms of digital...
By Dacey Rankins 2026-02-12 20:29:52 0 5K
Productivity
What does a healthy work-life balance look like?
What Does a Healthy Work-Life Balance Look Like? The concept of work-life balance is widely...
By Michael Pokrovski 2026-03-25 18:58:47 0 3K
Television
FOX 29, Live TV. Philadelphia USA
Fox 29 — which may also be called Fox News 29, or WTXF — has a great live stream....
By Nikolai Pokryshkin 2022-09-18 09:09:19 0 49K
Business
What Types of Content Resonate Most with Audiences on Different Platforms?
In the world of content creation, understanding the type of content that resonates with your...
By Dacey Rankins 2025-02-18 15:16:46 0 12K
Human Resources
How Does Personnel Management Improve Productivity?
Productivity is a key measure of organizational success, reflecting how efficiently...
By Dacey Rankins 2026-04-11 21:44:29 0 2K

BigMoney.VIP Powered by Hosting Pokrov