JavaScript Map

0
12χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Financial Services
Beyond GDP: other ways to measure the economy
Key points Gross national product, or GNP, includes what is produced...
από Mark Lorenzo 2023-03-03 19:43:30 0 21χλμ.
Business
How Do I Set Meaningful KPIs (Key Performance Indicators)?
Key Performance Indicators (KPIs) are essential tools that organizations use to measure progress...
από Dacey Rankins 2025-08-27 14:45:58 0 6χλμ.
Mental Health
Autism Spectrum
The autism spectrum, often referred to as just autism, autism spectrum disorder (ASD) or...
από Kelsey Rodriguez 2023-02-10 18:14:34 0 14χλμ.
Social Issues
Man on Wire (2008)
A look at tightrope walker Philippe Petit's daring, but illegal, high-wire routine performed...
από Leonard Pokrovski 2023-07-30 20:26:32 0 523χλμ.
Photography
Photography: A Journey Through Time
Photography, an art and science that captures moments in time, has undergone remarkable...
από Dacey Rankins 2024-10-09 16:56:05 0 17χλμ.

BigMoney.VIP Powered by Hosting Pokrov