JavaScript Map

0
13KB

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.

Suche
Kategorien
Mehr lesen
Human Resources
Why Knowledge Capital Is Important in the Digital Economy
The global economy has undergone a profound transformation over the past few decades, shifting...
Von Dacey Rankins 2026-03-26 15:39:31 0 927
Business
What About Licensing and Serverless Capabilities?
When organizations explore Microsoft Fabric, one of the most pressing questions that comes up is:...
Von Dacey Rankins 2025-09-02 15:35:18 0 8KB
Usenet
Usenet
Usenet is a computer network used for communication and...
Von Michael Pokrovski 2024-04-01 21:51:50 0 20KB
Business
Survey Design: Satisfaction, Ease-of-Use, and Suggestions
A well-designed survey can provide critical insights into user experiences, helping teams improve...
Von Dacey Rankins 2025-07-30 11:31:45 0 8KB
Business
How Do I Handle Difficult Coworkers or Clients?
Handling difficult coworkers or clients is an essential skill in office administration and...
Von Dacey Rankins 2026-04-22 15:17:45 0 1KB

BigMoney.VIP Powered by Hosting Pokrov