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.

Поиск
Категории
Больше
Marketing and Advertising
How is Copywriting Different From Content Writing?
A Complete Guide to Understanding the Two Pillars of Modern Marketing In the digital age, words...
От Dacey Rankins 2025-09-30 15:59:37 0 3Кб
Business
How Do I Protect My Startup Idea?
Starting a business begins with a great idea, but that idea is vulnerable to being copied,...
От Dacey Rankins 2025-04-10 14:47:47 0 11Кб
Безопасность
Best VPNs
The essence is simple: you install a program that establishes a connection to a remote server...
От FWhoop Xelqua 2023-05-02 20:06:53 0 17Кб
Социальные проблемы
Подозрительные лица. The Usual Suspects. (1995)
Если есть преступление, есть и мотив. Если проводится опознание, то по крайней мере есть один...
От Nikolai Pokryshkin 2022-12-01 21:43:39 0 27Кб
Business
What Are Performance Indicators (KPIs)?
In business management, one phrase that appears constantly in conversations about success and...
От Dacey Rankins 2025-08-27 15:06:43 0 5Кб

BigMoney.VIP Powered by Hosting Pokrov