JavaScript Map

0
12K

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
Do You Have Any Questions for Us? A Chance for Candidates to Demonstrate Their Interest and Understanding of the Company
One of the most commonly overlooked yet crucial moments in any job interview is when the...
By Dacey Rankins 2025-06-19 18:42:08 0 13K
Business
What Key Decisions Need to Be Made—And by Whom? Clarifying Governance, Approval Processes, and Roles
Clear decision-making is a cornerstone of successful project management. Knowing what decisions...
By Dacey Rankins 2025-07-11 19:58:46 0 6K
Business
Prepare Thoughtful Questions: Show Interest and Initiative in Interviews
One of the most overlooked opportunities in a job interview comes at the end when the interviewer...
By Dacey Rankins 2025-06-20 17:07:48 0 8K
Business
What Are the Key Functions of Sales Management?
Sales management is not a single task — it’s a set of interdependent functions that...
By Dacey Rankins 2025-12-18 20:31:24 0 2K
Shopping
Best Computers of 2022
The computer has long been an integral part of the life of modern man. These devices vary in...
By FWhoop Xelqua 2022-10-30 17:39:51 0 34K

BigMoney.VIP Powered by Hosting Pokrov