JavaScript Map

0
13χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Mental Health
Dyslexia: Management
Through the use of compensation strategies, therapy and educational support, individuals with...
από Kelsey Rodriguez 2023-07-04 19:34:01 0 13χλμ.
Human Resources
What is Human Resources (HR)?
Every successful organization—whether a small startup or a multinational...
από Dacey Rankins 2026-03-18 16:09:39 0 2χλμ.
Environment
Understanding the Business Environment: Key Factors and Their Impact on Success
In the world of business, the environment in which companies operate plays a significant role in...
από Dacey Rankins 2024-11-20 18:13:20 0 15χλμ.
Marketing and Advertising
What Are the 4 Ps of Marketing? The Complete Guide to the Marketing Mix (with Examples)
Introduction: The Foundation of Every Successful Marketing Strategy Every successful marketing...
από Dacey Rankins 2025-10-10 20:23:02 0 3χλμ.
Personal Finance
What Is a Mortgage?
What Is a Mortgage? A mortgage is a long-term loan secured by real property — usually a...
από Leonard Pokrovski 2025-11-13 17:30:12 0 7χλμ.

BigMoney.VIP Powered by Hosting Pokrov