JavaScript Map

0
12KB

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.

Pesquisar
Categorias
Leia mais
Marketing and Advertising
How Do I Measure Newspaper Advertising Effectiveness?
One of the most common criticisms of newspaper advertising is that it’s “hard to...
Por Dacey Rankins 2026-01-26 16:19:03 0 1KB
Marketing and Advertising
What Equipment Do I Need to Vlog? Can I Vlog With Just My Phone?
Introduction One of the biggest misconceptions about vlogging is that you need expensive gear to...
Por Dacey Rankins 2025-11-11 18:16:34 0 4KB
Stories
The General. (1926)
After being rejected by the Confederate military, not realizing it was due to his crucial...
Por Leonard Pokrovski 2023-03-27 19:27:34 0 29KB
Personal Finance
What Is SSI and How Is It Different From SSDI?
What Is SSI and How Is It Different From SSDI? When people talk about disability benefits in the...
Por Leonard Pokrovski 2025-12-11 20:05:22 0 3KB
Business
Why Pay for Analytics Tools?
In today’s digital economy, businesses of all sizes generate massive amounts of data every...
Por Dacey Rankins 2025-08-28 17:51:37 0 6KB

BigMoney.VIP Powered by Hosting Pokrov