JavaScript Map

0
12Кб

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.

Поиск
Категории
Больше
Business and Corporate Finance
How Do I Manage Cash Flow in a Small Business?
How Do I Manage Cash Flow in a Small Business?Budgeting and Forecasting Explained Managing cash...
От Leonard Pokrovski 2026-01-06 07:23:47 0 4Кб
Marketing and Advertising
What Are the Downsides or Common Criticisms of MLMs?
Introduction Multilevel marketing (MLM) has long been marketed as a pathway to financial...
От Dacey Rankins 2025-10-20 17:14:12 0 5Кб
Mental Health
Psychosis: Causes Pt.2
Psychiatric disordersFrom a diagnostic standpoint, organic disorders were believed to be caused...
От Kelsey Rodriguez 2023-05-25 18:55:36 0 11Кб
Economics
What are non-tariff barriers in commercial policy?
Non-tariff barriers (NTBs) are policy measures—other than ordinary customs...
От Leonard Pokrovski 2026-02-26 17:26:42 0 1Кб
Philosophy
What is Philosophy?
What is called philosophy is sometimes considered an occupation that everyone can do, and...
От FWhoop Xelqua 2022-11-10 11:55:27 0 24Кб

BigMoney.VIP Powered by Hosting Pokrov