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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Social Issues
Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb. (1964)
An insane American general orders a bombing attack on the Soviet Union, triggering a path to...
από Leonard Pokrovski 2022-12-25 19:47:28 0 25χλμ.
Business
What Ethical Considerations Are Involved in Influencer Marketing?
Influencer marketing has become one of the most prominent strategies in digital marketing today....
από Dacey Rankins 2025-02-28 15:57:27 0 9χλμ.
Природа и наука
Спирит Непокорный. Spirit Untamed. (2021)
Лаки Прескотт — юная бунтарка, совсем как ее мама, легендарная бесстрашная наездница,...
από Nikolai Pokryshkin 2022-09-17 10:56:53 0 32χλμ.
Lifestyle Choices
How to work less and get more: 4 main mistakes of all workaholics
Many of us grew up with the belief that you can only make a lot of money by working hard and...
από FWhoop Xelqua 2023-02-19 16:40:49 0 21χλμ.
Mental Health
Psychosis: Causes Pt.2
Psychiatric disordersFrom a diagnostic standpoint, organic disorders were believed to be caused...
από Kelsey Rodriguez 2023-05-25 18:55:36 0 11χλμ.

BigMoney.VIP Powered by Hosting Pokrov