JavaScript Map

0
12χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Economics
How Does Development Economics Address Poverty?
How Does Development Economics Address Poverty? Poverty remains one of the most persistent...
από Leonard Pokrovski 2026-03-11 23:26:41 0 4χλμ.
Business
What Is a Session?
When analyzing website performance in Google Analytics, one of the most frequently encountered...
από Dacey Rankins 2025-08-30 00:50:41 0 8χλμ.
Business
Who Will I Report To?
Understanding who you will report to is critical for determining how your role fits within the...
από Dacey Rankins 2025-08-09 18:29:48 0 7χλμ.
Financial Services
Indexing and its limitations
Key points A payment is said to be indexed if it is automatically...
από Mark Lorenzo 2023-03-24 19:47:37 0 14χλμ.
Marketing and Advertising
How to Plan a Guerrilla Marketing Campaign
From idea generation to execution: a step-by-step guide. Introduction: Turning Creativity into...
από Dacey Rankins 2025-10-07 17:40:37 0 7χλμ.

BigMoney.VIP Powered by Hosting Pokrov