JavaScript Map

0
6KB

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
Nach Verein filtern
Read More
Arts, Culture and Entertainment
Singin' in the Rain. (1952)
A silent film star falls for a chorus girl just as he and his delusionally jealous screen partner...
Von Leonard Pokrovski 2023-01-08 20:06:40 1 15KB
Personal Finance
How to estimate cash flows
What will you learn?   What is free cash flow?   How to keep...
Von FWhoop Xelqua 2022-10-08 11:40:49 0 21KB
Television
RTД Documentary Channel. Live TV. Russia.
Documentary channel RT Doc joined the RT news family in 2011. Since then, RT Doc has produced and...
Von Nikolai Pokryshkin 2022-11-15 18:42:42 0 24KB
Travel
Top 5 Zoos
Top 5 best zoos in the worldNot only a child, but also an adult can be delighted with spending...
Von FWhoop Xelqua 2023-05-06 17:56:31 0 21KB
Business
What is a business model?
A business model is a crucial component of any company, whether it's a startup or an established...
Von Dacey Rankins 2025-01-09 15:23:12 0 3KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov