JavaScript Map

0
6K

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
Business
What are the dangers of cannibalization in SEO and how to avoid it
Pages of the same site can compete with each other in search results. This is due to the...
By Dacey Rankins 2024-09-09 18:52:34 0 6K
Hacking
Hacking as a business. Is it possible to make money from this?
Hello, dear friends. Hacking, the illegal use of computer technology to gain unauthorized access...
By Michael Pokrovski 2024-03-25 20:41:23 0 15K
Sport
Sisters on Track (2021)
A coming of age story about hope, belonging, and the metaphorical and literal sisterhood of young...
By Leonard Pokrovski 2022-09-02 18:21:53 0 21K
Mailing Lists
Understanding Internet Mailing Lists: What They Are and How They Work
In today’s digital world, communication is key, whether you're sending emails to a few...
By Dacey Rankins 2024-11-26 14:43:08 0 3K
Mental Health
The Influence of Competition on Human Behavior and Social Interactions
Competition is a powerful force that shapes human behavior and social interactions in profound...
By Dacey Rankins 2025-01-14 14:52:07 0 2K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov