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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Consumer Electronics
7 Tips for Buying Consumer Electronics Online
Buying consumer electronics via the Internet is quite simple – potential buyers of goods...
από FWhoop Xelqua 2022-09-02 10:06:53 0 42χλμ.
Internet
How to use neural networks to write a script for TikTok, Reels and Shorts
In 2023, neural networks continue to be one of the most actively developing areas. In recent...
από FWhoop Xelqua 2023-06-12 20:21:19 0 35χλμ.
Business
What’s a Habit I Can Develop to Improve My Life?
  If there’s one truth about self-improvement, it’s that big change comes from...
από Dacey Rankins 2025-09-08 08:08:52 0 4χλμ.
Business
How Important Are Soft Skills and Growth Opportunities?
In today’s competitive job market, employers are realizing that technical skills alone...
από Dacey Rankins 2025-08-12 14:13:13 0 5χλμ.
Financial Services
Decisions with a budged constraint
Key points The budget constraint is the boundary of...
από Mark Lorenzo 2023-02-13 15:15:43 0 16χλμ.

BigMoney.VIP Powered by Hosting Pokrov