JavaScript Map

0
10KB

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 to Respect Start/End Times? Keeping Meetings Punctual and On-Time
Meeting punctuality is more than just good etiquette—it's essential for team productivity...
Von Dacey Rankins 2025-08-04 18:20:36 0 1KB
Mental Health
Psychosis: Medical Conditions
A very large number of medical conditions can cause psychosis, sometimes called secondary...
Von Kelsey Rodriguez 2023-05-26 18:17:32 0 10KB
Real Estate
How to choose an apartment? Basic tips when buying a home
The question of how to choose an apartment can seem too complicated – especially if you...
Von FWhoop Xelqua 2022-09-26 10:37:51 0 27KB
Mental Health
Psychosis: Methamphetamine
Methamphetamine induces a psychosis in 26–46 percent of heavy users. Some of these people...
Von Kelsey Rodriguez 2023-06-01 20:13:12 0 9KB
Cooking
Top 5 Home Meals to Cook: Delicious, Easy, and Comforting Recipes
Cooking at home can be both rewarding and enjoyable, especially when you prepare meals that are...
Von Dacey Rankins 2024-10-11 16:10:52 0 23KB

BigMoney.VIP Powered by Hosting Pokrov