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.

Suche
Kategorien
Mehr lesen
Marketing and Advertising
What Mistakes Should I Avoid in Google AdWords?
Google AdWords (Google Ads) is one of the most powerful advertising platforms available, but it...
Von Dacey Rankins 2026-01-13 14:53:44 0 4KB
Marketing and Advertising
What Industries Spend the Most on Advertising?
Advertising drives awareness, engagement, and revenue, but not all industries invest in it...
Von Dacey Rankins 2026-01-06 15:32:58 0 3KB
Domestic Services
20 most popular jobs
Over time, interest in some services is falling, and for others, consumer demand is increasing....
Von FWhoop Xelqua 2022-11-28 14:59:39 0 43KB
Социальные проблемы
Карты, деньги, два ствола. Lock, Stock and Two Smoking Barrels. (1998)
Четверо молодых парней накопили каждый по 25 тысяч фунтов, чтобы один из них мог сыграть в карты...
Von Nikolai Pokryshkin 2023-03-04 12:57:43 0 38KB
Personal Finance
Do Salary Negotiations Hurt My Chances of Getting the Job?
Do Salary Negotiations Hurt My Chances of Getting the Job? Salary negotiation is one of the most...
Von Leonard Pokrovski 2025-12-01 21:42:12 0 13KB

BigMoney.VIP Powered by Hosting Pokrov