JavaScript Map

0
7Кб

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.

Поиск
Категории
Больше
Financial Services
Elasticity and tax revenue
Key points Tax incidence is the manner in which the tax burden is divided...
От Mark Lorenzo 2023-04-13 20:08:37 0 10Кб
Financial Services
The effect of time on your retirement account
The effect of time on your retirement account When you’re young,...
От Mark Lorenzo 2023-05-26 18:53:26 0 8Кб
Visual Arts
Navigating the Palette: A Guide to Shopping for Visual Arts
Navigating the Palette: A Guide to Shopping for Visual Arts Introduction:In the realm of visual...
От Leonard Pokrovski 2024-06-03 22:04:05 0 21Кб
Социальные проблемы
Квартира. The Apartment. (1960)
Скромный служащий страховой компании Бакстер, чтобы хоть как-то продвинуться по карьерной...
От Nikolai Pokryshkin 2023-01-18 22:38:50 0 20Кб
Satire
Satirical News
Satirical (humorous, humorous, parody) news is completely or partially invented information about...
От FWhoop Xelqua 2023-02-28 19:30:00 0 13Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov