JavaScript Map

0
11K

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.

Căutare
Categorii
Citeste mai mult
Business
What Are the Top Priorities or Expectations for This Role in the First 6 Months?
Understanding the top priorities for a role early on can help you decide whether it’s the...
By Dacey Rankins 2025-08-12 15:31:43 0 5K
Business
How Can I Validate My Startup Idea Before Launching?
One of the most critical steps in launching a successful startup is ensuring that your idea has a...
By Dacey Rankins 2025-03-24 15:27:36 0 15K
Деньги
Финансовая Энергия
Как энергия экстрасенсов работает для привлечения финансов и улучшения материального...
By Nikolai Pokrovski 2024-12-17 21:43:24 0 21K
Gaelic
Gaelic: Unveiling the Rich Heritage and Enduring Legacy of Ireland's Indigenous Culture
  Gaelic: Unveiling the Rich Heritage and Enduring Legacy of...
By Leonard Pokrovski 2024-06-25 16:50:48 0 24K
Virtual Reality
The Death of Virtual Reality: What VR Technologies Have in Store for the Home
Three-dimensional bummer Seven years. That's how long it has been since the incredible success...
By Dacey Rankins 2024-04-01 17:47:50 0 16K

BigMoney.VIP Powered by Hosting Pokrov