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.

Zoeken
Categorieën
Read More
Economics
What is the cost of borrowing?
What Is the Cost of Borrowing? The cost of borrowing is the total amount a person or business...
By Leonard Pokrovski 2026-08-10 00:16:55 0 917
Business
How Do Marketplace Fees Work?
The first thing many sellers notice about a marketplace is the opportunity. The second thing...
By Dacey Rankins 2026-06-15 15:51:13 0 4K
Business
How Do Marketplaces Scale?
The first marketplace I analyzed looked unstoppable. Customer sign-ups were climbing every...
By Dacey Rankins 2026-06-30 05:35:51 0 2K
Pre-School
The Importance of Preschool: Laying the Foundation for Lifelong Learning
Preschool is often seen as the first formal experience for young children before they enter...
By Dacey Rankins 2024-11-27 17:49:03 0 18K
Personal Finance
What Tax Advantages Come with Charitable Donations?
What Tax Advantages Come with Charitable Donations? Itemizing vs. Standard Deduction,...
By Leonard Pokrovski 2025-12-24 18:14:00 0 6K

BigMoney.VIP Powered by Hosting Pokrov