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
Television
FOX 9 Live TV, Minneapolis-St. Paul USA
Minneapolis-St. Paul news, Minnesota weather, traffic and sports from FOX 9, serving the Twin...
By Nikolai Pokryshkin 2022-09-21 08:26:12 0 36K
Marketing and Advertising
What Is a Product Launch (and How to Execute It Successfully)?
Introduction: The Moment of Truth for Every Business Every company — from global giants to...
By Dacey Rankins 2025-10-29 15:00:22 0 2K
Business
How is Microsoft Fabric Different from Power BI?
When businesses hear about Microsoft Fabric, one of the most common questions is: “How does...
By Dacey Rankins 2025-09-01 09:31:54 0 5K
Marketing and Advertising
How Do I Add AdSense to My Website?
Adding Google AdSense to your website is one of the most common ways to monetize online content....
By Dacey Rankins 2025-12-26 22:24:09 0 3K
Personal Finance
How to Choose Investments and Build the Right Portfolio for You
How to Choose Investments and Build the Right Portfolio for You When people first begin...
By Leonard Pokrovski 2025-11-04 22:29:32 0 4K

BigMoney.VIP Powered by Hosting Pokrov