JavaScript Map

0
11KB

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.

Rechercher
Catégories
Lire la suite
Business
Can Startups That Have Already Received Funding Join an Accelerator?
Yes, startups that have already received funding can absolutely join an accelerator. While many...
Par Dacey Rankins 2025-04-23 16:52:19 0 12KB
Television
Medibiz TV. Live TV, Dubai - United Arab Emirates. (English)
Medi BizTV is a 24 hour free to air satellite TV channel dedicated to serve and spread the...
Par Nikolai Pokryshkin 2023-03-04 15:05:40 0 47KB
Business
What Are Common Questions Asked in Interviews About Conflict Resolution?
Conflict resolution is a critical competency in the modern workplace. During interviews, hiring...
Par Dacey Rankins 2025-08-05 14:55:19 0 3KB
Marketing and Advertising
How Do Local Mobile Searches Behave / How to Optimize for “Near Me” Searches
Introduction “Near me” searches have become one of the defining behaviors of the...
Par Dacey Rankins 2025-10-17 15:24:32 0 762
Cultures and Groups
Understanding Cultures: Diversity, Identity, and the Tapestry of Humanity
Culture is the essence of what makes a group of people unique. It encompasses the shared beliefs,...
Par Dacey Rankins 2024-11-07 16:38:01 0 13KB

BigMoney.VIP Powered by Hosting Pokrov