JavaScript Map

0
6KB

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.

Rechercher
Catégories
Lire la suite
Associations
What does the presence of a business association give?
What does the association give to business?Business associations are one example of people coming...
Par FWhoop Xelqua 2023-07-19 19:20:14 0 11KB
Social Issues
The Forever Purge (2021)
All the rules are broken as a sect of lawless marauders decides that the annual Purge does not...
Par Leonard Pokrovski 2022-09-11 19:54:57 0 22KB
Телевидение
Инфо 24 - ТВ прямой эфир.
Телеканал «ИНФО 24» начал свое вещание в 2011 году.В 2022 году получил статус...
Par Nikolai Pokryshkin 2022-11-03 19:53:04 0 19KB
Телевидение
PUBLIKA Live TV. Телевидение на русском, молдавском и румынском.
Телевидение Молдавии на русском и молдавском языках. Новости, погода, политика, происшествия и...
Par Nikolai Pokryshkin 2022-10-31 14:28:01 0 21KB
Life Issues
Rear Window. (1954)
A wheelchair-bound photographer spies on his neighbors from his Greenwich Village courtyard...
Par Leonard Pokrovski 2022-12-09 19:36:34 0 18KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov