JavaScript Map

0
12χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Business
Why Is Mentoring Important? Unlocking Growth Through Meaningful Connections
Mentoring is far more than just a professional relationship—it’s a powerful...
από Dacey Rankins 2025-05-22 20:11:31 0 8χλμ.
Business
Do Incubators Take Equity in Startups?
Startup incubators provide a wide range of valuable services—from mentorship and networking...
από Dacey Rankins 2025-04-24 17:12:41 0 17χλμ.
Marketing and Advertising
What Types or Formats of Content Are Most Likely to Go Viral?
Introduction Every brand dreams of creating that one piece of content that everyone talks about...
από Dacey Rankins 2025-11-10 17:36:12 0 3χλμ.
Personal Finance
What Happens If I Miss a Payment?
What Happens If I Miss a Payment? Understanding the Consequences: Late Fees, Credit Impact, and...
από Leonard Pokrovski 2025-11-06 19:21:14 0 3χλμ.
Business
Situation, Task, Action, Result: Mastering the STAR Interview Method
When it comes to job interviews, few tools are as effective—or as widely...
από Dacey Rankins 2025-06-23 14:34:49 0 8χλμ.

BigMoney.VIP Powered by Hosting Pokrov