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
How to Adapt Etiquette for Different Cultures or Social Contexts: A Comprehensive Professional Guide
In our increasingly interconnected world, professional and social interactions often span...
Par Dacey Rankins 2025-11-21 18:39:24 0 6KB
Economics
The Role of Institutions in Development Economics
The Role of Institutions in Development Economics Development economics focuses on understanding...
Par Leonard Pokrovski 2026-03-13 01:31:54 0 3KB
Argent
How to Invest in Stocks
How to Invest in Stocks Investing in stocks is one of the most popular ways to build wealth over...
Par Leonard Pokrovski 2025-09-22 19:05:33 0 9KB
Marketing and Advertising
What Should B2B Leaders Ask to Drive Growth and Refine Marketing Strategy?
In today’s fast-moving business environment, B2B leaders face increasing pressure to...
Par Dacey Rankins 2025-09-20 15:50:33 0 7KB
Социальные проблемы
Новые времена. Modern Times. (1936)
«Новые времена» - это эмоциональный, выдержанный в комическом ключе, отклик на...
Par Nikolai Pokryshkin 2022-12-06 22:41:12 0 29KB

BigMoney.VIP Powered by Hosting Pokrov