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
Personal Finance
How to estimate cash flows
What will you learn?   What is free cash flow?   How to keep...
By FWhoop Xelqua 2022-10-08 11:40:49 0 29K
Business
What Do I Most Enjoy About My Life Today?
In a fast-paced world filled with constant demands, deadlines, and distractions, it’s easy...
By Dacey Rankins 2025-09-09 14:20:23 0 6K
Business
Is It Necessary to Learn Formal Etiquette in Today’s Casual Society?
We live in a world that has undergone dramatic cultural transformation over the past century....
By Dacey Rankins 2025-11-21 17:24:57 0 7K
Human Resources
What Are Performance Appraisal Methods?
Performance appraisal is a key function of personnel management that involves systematically...
By Dacey Rankins 2026-04-10 20:09:11 0 2K
Marketing and Advertising
How Much Does Influencer Marketing Cost? / How Much Do Influencers Charge?
Understanding pricing, factors, and budgeting for influencer campaigns Introduction: The Cost...
By Dacey Rankins 2025-10-07 17:47:06 0 9K

BigMoney.VIP Powered by Hosting Pokrov