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
Agriculture
Agricultural Sciences
Agricultural sciences are a broad, interdisciplinary field that encompasses parts of the exact,...
Von FWhoop Xelqua 2023-04-18 18:07:48 0 19KB
Financial Services
The Production Possibilities Frontier
Key Points The Production Possibilities Frontier (PPF) is a graph that shows all the...
Von Mark Lorenzo 2023-04-05 17:09:37 0 14KB
Business
What’s the Difference Between Recruitment and Selection?
Although the terms recruitment and selection are often used interchangeably, they refer to two...
Von Dacey Rankins 2025-08-12 14:03:02 0 7KB
Tile Games
Mahjong
Mahjong...
Von Leonard Pokrovski 2024-04-10 00:43:57 0 17KB
Productivity
How can I save money fast?
How Can I Save Money Fast? Saving money quickly is a goal that often arises out of...
Von Michael Pokrovski 2026-03-31 18:44:35 0 12KB

BigMoney.VIP Powered by Hosting Pokrov