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.

Zoeken
Categorieën
Read More
Hacking
Hacking as a business. Is it possible to make money from this?
Hello, dear friends. Hacking, the illegal use of computer technology to gain unauthorized access...
By Michael Pokrovski 2024-03-25 20:41:23 0 25K
Business
Describe a Launch You Worked On—What Went Well? What Would You Change?
Every product marketer or product manager can point to a launch that shaped their career. Product...
By Dacey Rankins 2025-09-16 16:16:34 0 7K
Business
The Intersection of Customer Experience and Professional Creativity in the Insurance Industry
In the competitive landscape of general insurance, the customer experience (CX) has emerged as a...
By Nikolai Pokryshkin 2024-10-05 15:00:04 0 35K
Personal Finance
How Long Does Credit Repair Take?
How Long Does Credit Repair Take? Improving your credit score can feel like a long and uncertain...
By Leonard Pokrovski 2025-10-22 12:43:59 0 6K
Business
What is corporate culture and why do organizations need it?
What is corporate culture and why do organizations need it? The concept of corporate...
By Leonard Pokrovski 2024-08-13 22:16:13 0 17K

BigMoney.VIP Powered by Hosting Pokrov