JavaScript Map

0
5K

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.

Search
Categories
Read More
Systems
Computers - How they have come to be, and what they are
Computer (English computer, IPA: [kəmˈpjuː.tə(ɹ)]- "calculator", from the Latin computare - to...
By FWhoop Xelqua 2023-02-16 15:33:57 0 13K
Programming
Python Assert
The assert keyword is used when debugging code. The assert keyword lets you...
By Jesse Thomas 2023-03-21 21:48:28 0 5K
Recreation
Exploring the Essence of Recreation: Finding Joy, Balance, and Renewal
Recreation is not merely a break from routine; it's an essential aspect of human existence,...
By Dacey Rankins 2024-05-13 20:45:19 0 8K
Social Issues
Hamilton. (2020)
The real life of one of America's foremost founding fathers and first Secretary of the Treasury,...
By Leonard Pokrovski 2022-10-21 16:42:21 0 16K
Central America
Why can't you travel from North America to South America by car
North and South America are connected by a narrow strip of land - the Isthmus of Panama, several...
By FWhoop Xelqua 2023-03-07 18:03:02 0 10K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov