JavaScript Map

0
12K

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
Finance
Top 8 Most Expensive Currencies in the World - 2024 Ranking
The size of inflation and interest rates, the scale of unemployment, GDP, fluctuations in stock...
By Dacey Rankins 2024-10-22 17:31:36 0 17K
Science Fiction and Fantasy
The Super Mario Bros. Movie. (2023)
A plumber named Mario travels through an underground labyrinth with his brother, Luigi, trying to...
By Leonard Pokrovski 2023-06-11 14:29:44 0 30K
Business
Understanding Market Competition and Its Impact on Business and Economics
Market competition plays a fundamental role in shaping the behavior of businesses and the...
By Dacey Rankins 2025-01-13 14:53:05 0 13K
Internet
How to become popular on tiktok
The following recommendations will help you quickly become popular on Tik Tok:Define your goal....
By FWhoop Xelqua 2023-05-31 18:00:14 0 23K
Business
Marketing Plan: What It Is and How to Make It Marketing Plan
Marketing Plan: What It Is and How to Make It Marketing Plan Let's take a look at what a...
By Leonard Pokrovski 2024-08-22 13:48:30 0 17K

BigMoney.VIP Powered by Hosting Pokrov