JavaScript Map

0
12K

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.

Cerca
Categorie
Leggi tutto
Programming
Python Pygame
If you are just getting started with pygame, you should be able to get started fairly quickly....
By Jesse Thomas 2023-03-29 19:03:26 0 11K
Mental Health
Psychosis: Alcohol
Approximately three percent of people with alcoholism experience psychosis during acute...
By Kelsey Rodriguez 2023-05-30 18:49:34 0 12K
Life Issues
Grave of the Fireflies. (1988)
The story of Seita and Setsuko, two young Japanese siblings, living in the declining days of...
By Leonard Pokrovski 2022-12-06 20:01:30 0 23K
Business
How Do I Use Visuals or Slides Effectively During a Speech?
Slides can make your speech stronger — or weaker. When used well, they help your audience...
By Dacey Rankins 2025-12-11 16:43:00 0 2K
Marketing and Advertising
How Should We Position and Market the Product?
Launching a new product is not just about having something great — it’s about making...
By Dacey Rankins 2025-10-29 15:17:40 0 6K

BigMoney.VIP Powered by Hosting Pokrov