JavaScript Map

0
13KB

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.

Rechercher
Catégories
Lire la suite
Business
What Is Growth Hacking?
In today’s fast-paced digital landscape, businesses are under constant pressure to grow...
Par Dacey Rankins 2025-09-11 16:25:46 0 7KB
Financial Services
Investing in human capital
Key points Almost universally, economists agree that it is a good individual...
Par Mark Lorenzo 2023-05-10 18:45:31 0 15KB
Социальные проблемы
Секреты Лос-Анджелеса. L.A. Confidential. (1997)
Бад Уайт и Эд Эксли работают в полиции Лос-Анджелеса. Они настолько разные, что порой ненавидят...
Par Nikolai Pokryshkin 2023-01-29 11:40:28 0 25KB
Спорт
Дом на глубине. The Deep House. (2021)
Видеоблогеры Тина и Бен путешествуют по миру, снимая старые заброшенные здания. Решив впечатлить...
Par Nikolai Pokryshkin 2022-09-03 20:34:06 0 41KB
Business
What Are Virtual Machines?
Most people encounter virtual machines long before they understand what they are. They launch an...
Par Dacey Rankins 2026-06-05 03:34:19 0 5KB

BigMoney.VIP Powered by Hosting Pokrov