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.

Suche
Kategorien
Mehr lesen
Marketing and Advertising
What Is PPC Remarketing or Retargeting?
PPC remarketing, also known as retargeting, is one of the most powerful strategies in digital...
Von Dacey Rankins 2026-02-05 18:46:44 0 6KB
Economics
What is marginal utility?
What Is Marginal Utility? A restless measure of satisfaction—and the quiet engine behind...
Von Leonard Pokrovski 2026-05-05 08:55:17 0 3KB
Ужасы
Дьявол в деталях. The Little Things. (2021)
Октябрь 1990 года. Уже немолодого заместителя окружного шерифа Джо Дикона по прозвищу Дики...
Von Nikolai Pokryshkin 2022-09-21 17:31:15 0 43KB
Marketing and Advertising
How Long Should Retargeting Audience Windows Be? A Complete Guide to 7, 30, 90, and 180-Day Audiences
One of the most important decisions in retargeting is not who to target, but how long to target...
Von Dacey Rankins 2026-02-16 14:39:33 0 5KB
Economics
What are leading economic indicators?
What Are Leading Economic Indicators? An economy does not collapse all at once. Nor does it...
Von Leonard Pokrovski 2026-05-18 20:57:01 0 3KB

BigMoney.VIP Powered by Hosting Pokrov