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.

Suche
Kategorien
Mehr lesen
Personal Finance
How Much Can I Borrow and How Long Will I Have to Repay the Loan?
How Much Can I Borrow and How Long Will I Have to Repay the Loan? Understanding Loan Amounts,...
Von Leonard Pokrovski 2025-11-05 15:58:48 0 16KB
Mental Health
ADHD: Paradoxical reaction to neuroactive substances
Another sign of the structurally altered signal processing in the central nervous system in this...
Von Kelsey Rodriguez 2023-04-18 18:10:52 0 13KB
Economics
Is credit card interest calculated daily?
Is Credit Card Interest Calculated Daily? Yes, in most cases, credit card interest is calculated...
Von Leonard Pokrovski 2026-08-05 22:41:31 0 3KB
Business
What If Scope or Requirements Change Mid-Project? Handling Scope Creep: Assess Impact, Communicate Changes, Update Plan
In an ideal world, project requirements stay fixed from start to finish. But in reality, change...
Von Dacey Rankins 2025-07-14 15:18:49 0 12KB
Productivity
How to change my life through goal setting?
The Alchemy of Intent Most people treat goal setting as a shopping list for a better life....
Von Michael Pokrovski 2026-05-06 19:42:42 0 3KB

BigMoney.VIP Powered by Hosting Pokrov