JavaScript Map

0
11K

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.

Search
Categories
Read More
Телевидение
Телеканал Доктор Градус. Прямая трансляция.
Телеканал «Доктор Градус» целиком посвящен нетрадиционной медицине. При просмотре...
By Nikolai Pokryshkin 2022-11-18 12:54:04 0 24K
Disabled
Navigating the Complexities of Disability in Modern Society
Navigating the Complexities of Disability in Modern Society Introduction:In the mosaic of human...
By Leonard Pokrovski 2024-06-06 18:38:08 0 21K
Social Issues
Ben-Hur. (1959)
After a Jewish prince is betrayed and sent into slavery by a Roman friend in 1st-century...
By Leonard Pokrovski 2023-03-24 20:02:07 0 26K
Science Fiction and Fantasy
Avengers: Endgame. (2019)
After the devastating events of Avengers: Infinity War (2018), the universe is in ruins. With the...
By Leonard Pokrovski 2023-01-03 21:03:41 0 27K
Business
How Do I Build the Right Team?
Building the right team is one of the most critical steps in achieving success for your business....
By Dacey Rankins 2025-03-05 16:27:39 0 13K

BigMoney.VIP Powered by Hosting Pokrov