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
Life Issues
A Teacher. (2013)
A high school teacher in Austin, Texas takes sexual advantage over one of her students. Her life...
By Leonard Pokrovski 2023-05-06 17:34:10 0 40K
Business
What Legal Mistakes Do Startup Founders Make?
Starting a business is a thrilling journey, but it comes with a fair share of challenges,...
By Dacey Rankins 2025-04-10 14:54:26 0 10K
Business
What Are the Common Presentation Mistakes?
Even the strongest ideas can fall flat if delivered poorly. Great presenters aren’t just...
By Dacey Rankins 2025-12-05 18:52:18 0 4K
Nature and Science
Grizzly Man (2005)
A devastating and heart-rending take on grizzly bear activists Timothy Treadwell and Amie...
By Leonard Pokrovski 2023-07-28 20:39:14 0 523K
Parties
Ideas for New Years Party
December is not only the month of summing up the results of the whole year, but also the time of...
By FWhoop Xelqua 2022-12-08 15:57:18 0 26K

BigMoney.VIP Powered by Hosting Pokrov