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.

Pesquisar
Categorias
Leia Mais
Business
How Can I Develop My Management Skills?
Developing management skills is a crucial step for anyone aiming to grow as a leader, influence a...
Por Dacey Rankins 2025-05-13 15:49:22 0 10K
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...
Por Dacey Rankins 2024-11-26 14:43:08 0 10K
Libraries
The Timeless Haven: Celebrating Libraries in the Digital Age
In an era where information seems to flow endlessly through digital channels, the significance of...
Por Dacey Rankins 2024-05-20 14:35:06 0 19K
Bibliography
Unlocking the Power of References in Bibliographies: A Comprehensive Guide
Unlocking the Power of References in Bibliographies: A Comprehensive Guide Bibliographies are...
Por Leonard Pokrovski 2024-05-16 23:57:31 0 16K
Finance
What is the Difference Between a Debit Card and a Credit Card?
What is the Difference Between a Debit Card and a Credit Card? When it comes to managing money,...
Por Leonard Pokrovski 2025-10-02 22:33:03 0 3K

BigMoney.VIP Powered by Hosting Pokrov