JavaScript Map

0
13χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Productivity
How do I create a productive daily routine?
How Do I Create a Productive Daily Routine? A productive daily routine provides structure,...
από Michael Pokrovski 2026-02-16 21:55:17 0 16χλμ.
Publications
Exploring the Vital Role of Publications: A Gateway to Knowledge
Exploring the Vital Role of Publications: A Gateway to Knowledge In the realm of academia,...
από Leonard Pokrovski 2024-05-25 00:19:18 0 31χλμ.
Business
What Are the Key Functions of Sales Management?
Sales management is not a single task — it’s a set of interdependent functions that...
από Dacey Rankins 2025-12-18 20:31:24 0 7χλμ.
Economics
What is business cycle theory?
The Quiet Logic Behind Economic Turbulence There is a peculiar regularity to economic disorder....
από Leonard Pokrovski 2026-05-05 09:15:45 0 3χλμ.
Decision Making and Problem Solving
How to improve memory naturally?
The mind is not a warehouse, and it is certainly not a hard drive. We operate under the...
από Michael Pokrovski 2026-07-17 01:01:36 0 342

BigMoney.VIP Powered by Hosting Pokrov