JavaScript Map

0
13K

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.

Site içinde arama yapın
Kategoriler
Read More
Customer Service
How Do You Calm Down an Upset Customer?
In customer service, interacting with upset customers is a situation that employees frequently...
By Dacey Rankins 2026-03-10 20:12:12 0 5K
Productivity
How to improve reading speed quickly?
To improve your reading speed quickly, you have to stop treating reading as a passive activity...
By Michael Pokrovski 2026-05-07 16:54:03 0 3K
Business
How Often Should I Ask for Feedback?
Asking for feedback is one of the most powerful habits a professional or leader can...
By Dacey Rankins 2025-07-28 14:51:58 0 3K
Business
High‑Level Exec Practices: “If Nvidia’s CEO Doesn’t Do Weekly 1:1s, Why Should I?”
Why Meeting Rhythms Should Reflect Role, Scope, and Team Needs A common refrain in management...
By Dacey Rankins 2025-08-01 14:12:16 0 16K
Business
How Long Does It Take to Make Money?
The first affiliate commission feels almost absurd. Not because it’s large. Usually,...
By Dacey Rankins 2026-05-15 13:21:31 0 2K

BigMoney.VIP Powered by Hosting Pokrov