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.

Site içinde arama yapın
Kategoriler
Read More
Business
How Can I Attract and Retain Talent in My Startup?
Attracting and retaining top talent is one of the most crucial aspects of growing a successful...
By Dacey Rankins 2025-03-04 14:38:37 0 18K
Weddings
The Ultimate Guide to Shopping for Your Dream Wedding: Making Every Moment Memorable
Shopping for your wedding can be both exhilarating and overwhelming. From finding the perfect...
By Dacey Rankins 2024-06-05 17:49:35 0 20K
Marketing and Advertising
Do You Have to Recruit People (Your "Downline") to Earn Income in MLM?
Introduction If you’ve ever been invited to join a multilevel marketing (MLM) opportunity,...
By Dacey Rankins 2025-10-20 17:09:48 0 10K
Economics
How Is Economic Development Measured?
How Is Economic Development Measured? Economic development refers to the process through which a...
By Leonard Pokrovski 2026-03-16 06:28:55 0 4K
Marketing and Advertising
How Do I Advertise on Facebook for Free?
One of the most searched questions about Facebook marketing is whether it’s possible to...
By Dacey Rankins 2026-01-22 19:48:54 0 4K

BigMoney.VIP Powered by Hosting Pokrov