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
Business
Meetings are a total waste of time. Here's how to make them useful
If you've ever sat through a meeting and left wondering, "What was the point of that?", you're...
Von Dacey Rankins 2025-06-03 13:21:34 0 11KB
Andere
Last Christmas. (2019)
Kate is a young woman subscribed to bad decisions. Working as an elf in a year round Christmas...
Von Leonard Pokrovski 2022-09-10 18:34:25 0 37KB
Economics
What is the role of institutions in comparative economics?
What is the role of institutions in comparative economics? Comparative economics asks a simple...
Von Leonard Pokrovski 2026-03-04 21:38:05 0 5KB
Business
What Happens If a Payment Fails?
Most membership organizations celebrate successful payments. They should. Every completed...
Von Dacey Rankins 2026-06-26 03:10:31 0 1KB
Business
How Do Marketplaces Make Money?
A marketplace can process millions of transactions without ever touching the products being sold....
Von Dacey Rankins 2026-06-16 16:05:44 0 3KB

BigMoney.VIP Powered by Hosting Pokrov