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.

Search
Categories
Read More
Business
What Are the Different Types of Crowdfunding?
Crowdfunding has emerged as an innovative and powerful way for individuals, startups, and...
By Dacey Rankins 2025-03-27 18:03:38 0 8K
Business
What Are Common Mistakes in Product Planning?
Product planning is one of the most critical responsibilities in product management. A strong...
By Dacey Rankins 2025-08-20 15:41:09 0 5K
Business
How Detailed Should a Startup Biography Be?
When crafting a startup biography, one common question arises: How much detail is too much? The...
By Dacey Rankins 2025-04-19 14:47:47 0 10K
Marketing and Advertising
What Mistakes Should I Avoid in Video Marketing? — How to Prevent Wasted Budget and Missed Opportunities
Introduction Video marketing is one of the most powerful tools available to modern businesses....
By Dacey Rankins 2025-11-10 17:10:58 0 1K
Business
How Does a Startup Incubator Work?
In today’s fast-paced entrepreneurial ecosystem, startup incubators play a vital role in...
By Dacey Rankins 2025-04-24 16:52:09 0 14K

BigMoney.VIP Powered by Hosting Pokrov