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.

Căutare
Categorii
Citeste mai mult
Human Resources
What Is the Role of Personnel Management in Conflict Resolution?
Conflict is a natural part of any workplace where individuals with different backgrounds,...
By Dacey Rankins 2026-04-13 17:17:04 0 1K
Marketing and Advertising
What Is the Difference Between User Acquisition and Retention?
In the world of digital marketing and growth strategy, user acquisition and user retention are...
By Dacey Rankins 2026-02-24 13:38:34 0 3K
Marketing and Advertising
What Are the Types of TV Ads?
Television advertising is not a one-size-fits-all marketing channel. Businesses have multiple ad...
By Dacey Rankins 2026-02-20 19:12:13 0 1K
Life Issues
Shutter Island. (2010)
In 1954, a U.S. Marshal investigates the disappearance of a murderer who escaped from a hospital...
By Leonard Pokrovski 2023-02-16 13:03:05 1 26K
Business
What Questions Do Venture Capitalists Ask Startups?
When pitching to venture capitalists (VCs), startups are often laser-focused on explaining their...
By Dacey Rankins 2025-04-30 13:00:22 0 10K

BigMoney.VIP Powered by Hosting Pokrov