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.

Site içinde arama yapın
Kategoriler
Read More
Социальные проблемы
Вся жизнь впереди. The Life Ahead. (2020)
Ещё совсем малышом сенегальский иммигрант Момо потерял мать. Сейчас ему 12, и он промышляет...
By Nikolai Pokryshkin 2022-10-08 19:59:15 0 36K
Recreation
Exploring the Essence of Recreation: Finding Joy, Balance, and Renewal
Recreation is not merely a break from routine; it's an essential aspect of human existence,...
By Dacey Rankins 2024-05-13 20:45:19 0 18K
Programming
Tailswind CSS Pros & Cons
What is Tailwind CSS? First released in May 2019, Tailwind CSS is...
By Jesse Thomas 2023-06-15 20:55:26 0 13K
Office Products
An Overview of Essential Office Products: Tools for Efficiency and Productivity
Office products are the unsung heroes that keep workplaces running smoothly, whether in a...
By Dacey Rankins 2024-12-03 15:31:48 0 13K
Business
What Are the Barriers to Business Growth?
Every entrepreneur dreams of scaling their business, but growth is rarely a straight path. Even...
By Dacey Rankins 2025-09-05 15:40:01 0 5K

BigMoney.VIP Powered by Hosting Pokrov