JavaScript Map

0
9K

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.

Căutare
Categorii
Citeste mai mult
Science Fiction and Fantasy
The Terminator. (1984)
A human soldier is sent from 2029 to 1984 to stop an almost indestructible cyborg killing...
By Leonard Pokrovski 2023-04-28 19:18:14 0 23K
Accounting
Collection of jokes about accountants and programmers
Collection of jokes about accountants and programmers Start the morning with a humorous...
By Leonard Pokrovski 2024-03-11 21:36:46 0 25K
Aviation
The fastest aircraft in the world and its competitors - How fast do they fly?
Modern aircraft are able to fly very fast. By "fast" I don't mean speeds 10 times faster than a...
By FWhoop Xelqua 2022-10-25 11:02:46 0 20K
Education and Training
MBA in the USA
There are more than 3,500 universities in the United States, and about 500 of them have MBA...
By FWhoop Xelqua 2023-07-27 18:17:09 0 520K
Business
What Are the Benefits of Mentoring for the Mentee?
Mentoring is a powerful tool for personal and professional growth. While the mentor provides...
By Dacey Rankins 2025-05-24 15:44:21 0 3K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov