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.

Site içinde arama yapın
Kategoriler
Read More
Productivity
How do I declutter my home?
How Do I Declutter My Home? Decluttering your home is more than just tidying up—it is a...
By Michael Pokrovski 2026-04-09 19:54:14 0 3K
Business
How to Identify and Qualify New Business Opportunities or Partnerships: A Complete 3,000-Word Guide
Introduction Identifying and qualifying business opportunities is one of the most critical...
By Dacey Rankins 2025-11-17 18:30:02 0 7K
Airsoft
A Comprehensive Guide to Airsoft: The Sport, Gear, and Community
Airsoft is an exciting, fast-paced sport that has grown in popularity over the years, attracting...
By Dacey Rankins 2024-11-29 15:09:59 0 14K
Business
How to manage subscriptions and unsubscribes to on-site and off-site newsletters
There are 2 pieces of news: bad and good. The bad news is that your subscriber base is degraded...
By Dacey Rankins 2024-09-27 15:16:00 0 29K
Productivity
How do I get better results with less effort?
Achieving better results with less effort is a central goal in productivity, performance...
By Michael Pokrovski 2026-03-24 22:11:03 0 5K

BigMoney.VIP Powered by Hosting Pokrov