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
Marketing and Advertising
What Is the Difference Between SEM and SEO? A Complete Comparison Guide for 2026
What Is the Diff When businesses want more visibility on search engines, they usually turn to...
Par Dacey Rankins 2026-02-17 16:24:07 0 5KB
Business
Service vs. Product-Based Business?
At some point, nearly every entrepreneur confronts the same uncomfortable question: Should you...
Par Dacey Rankins 2026-05-13 20:57:16 0 3KB
Decision Making and Problem Solving
What are lateral thinking techniques?
The Architecture of the Intellectual Escape Hatch We exist within the suffocating architecture...
Par Michael Pokrovski 2026-07-04 17:11:40 0 760
Business
How Do I Protect My Startup Idea?
Starting a business begins with a great idea, but that idea is vulnerable to being copied,...
Par Dacey Rankins 2025-04-10 14:47:47 0 15KB
Business
Social Media Marketing (SMM)
Why is social media so important for business?Social media marketing is the easiest way to reach...
Par Dacey Rankins 2024-09-09 19:05:21 0 15KB

BigMoney.VIP Powered by Hosting Pokrov




google-site-verification=q_0zhvNWwTfwbQ-uEJsvcmUKKbtOWUTgl3H57qDiFrg