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
Business
Can I Do Affiliate Marketing Without a Website?
For years, affiliate marketing advice sounded strangely obsessed with websites. Buy a...
Par Dacey Rankins 2026-05-16 21:50:55 0 5KB
Productivity
Why is work-life balance important for employee retention?
Why Is Work-Life Balance Important for Employee Retention? Employee retention has become one of...
Par Michael Pokrovski 2026-03-31 18:56:28 0 3KB
Business
What Are Your Strengths and Weaknesses?
This Assesses Self-Awareness and Honesty In almost every job interview, candidates face the...
Par Dacey Rankins 2025-06-18 14:52:38 0 14KB
Decision Making and Problem Solving
Why do consumers buy impulsively?
Why Do Consumers Buy Impulsively? The Split Second Between Intention and Action A person opens...
Par Michael Pokrovski 2026-06-08 20:40:51 0 2KB
Performance and Capacity
SSD with DRAM and without DRAM: understanding the differences
SSD with DRAM and without DRAM: understanding the differences Solid-state drives (SSDs) have...
Par Leonard Pokrovski 2024-03-28 22:10:50 0 24KB

BigMoney.VIP Powered by Hosting Pokrov