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.

Rechercher
Catégories
Lire la suite
Economics
How Does Capitalism Work?
How Does Capitalism Work?Markets, Ownership, and Incentives Capitalism is one of the most common...
Par Leonard Pokrovski 2026-02-06 23:18:06 0 6KB
Economics
What is the current state of the economy?
The current state of the global economy in 2026 can best be described as resilient but fragile....
Par Leonard Pokrovski 2026-03-28 05:21:21 0 3KB
Business
What office supplies are still necessary in a digital office?
The conference room table looked almost aggressively modern. Wireless chargers embedded into...
Par Dacey Rankins 2026-05-07 00:51:43 0 3KB
Marketing and Advertising
How Does Targeting Work in Online Advertising?
Targeting is the engine that powers effective online advertising. Without targeting, ads would be...
Par Dacey Rankins 2026-01-28 16:16:59 0 4KB
Business
What Are Performance Indicators (KPIs)?
In business management, one phrase that appears constantly in conversations about success and...
Par Dacey Rankins 2025-08-27 15:06:43 0 8KB

BigMoney.VIP Powered by Hosting Pokrov