JavaScript Map

0
13Кб

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.

Поиск
Категории
Больше
Laser Games
The Thrilling World of Laser Games: Where Strategy Meets Adventure
The Thrilling World of Laser Games: Where Strategy Meets Adventure In the realm of interactive...
От Leonard Pokrovski 2024-06-30 14:06:10 0 23Кб
Социальные проблемы
Суд над чикагской семёркой. The Trial of the Chicago 7. (2020)
Чикаго, 1968 год. Демонстрация против войны во Вьетнаме вылилась в стычки с полицией. Семь...
От Nikolai Pokryshkin 2022-10-09 18:18:42 0 38Кб
Социальные проблемы
Вся жизнь впереди. The Life Ahead. (2020)
Ещё совсем малышом сенегальский иммигрант Момо потерял мать. Сейчас ему 12, и он промышляет...
От Nikolai Pokryshkin 2022-10-08 19:59:15 0 43Кб
Productivity
How do I create a time management plan?
Time is a finite resource. Whether you are a student, a professional, an entrepreneur, or...
От Michael Pokrovski 2026-03-05 17:42:53 0 30Кб
Consumer Information
30 Things to Do When Buying Real Estate: A Complete Checklist
Only at first glance it seems that the main thing when buying an apartment is to find an...
От Dacey Rankins 2024-04-25 18:10:03 0 26Кб

BigMoney.VIP Powered by Hosting Pokrov