JavaScript Map

0
13KB

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.

Suche
Kategorien
Mehr lesen
Business
How Much Does It Cost? / What’s Included in the Price?
One of the first questions customers ask—whether shopping for software, consumer products,...
Von Dacey Rankins 2025-09-04 12:10:32 0 7KB
Mental Health
Psychosis: Delusions [2]
Studies during acute experiences of hallucinations demonstrate increased activity in primary or...
Von Kelsey Rodriguez 2023-06-06 19:14:32 0 12KB
Personal Finance
How to Create a Budget and Save Money: A Practical Guide to Managing Income, Expenses, and Spending
How to Create a Budget and Save Money: A Practical Guide to Managing Income, Expenses, and...
Von Leonard Pokrovski 2025-11-18 21:12:47 0 7KB
Business
B2C: how the relationship between business and buyer works
Features of B2C salesA business that is aimed at an ordinary buyer has its own characteristics....
Von Dacey Rankins 2024-09-02 19:00:28 0 14KB
Cooperatives
Understanding Business Cooperatives: A Model for Collective Success
In the world of business, there are many ways organizations can operate, but one of the most...
Von Dacey Rankins 2024-11-14 16:17:54 0 14KB

BigMoney.VIP Powered by Hosting Pokrov