JavaScript Map

0
9K

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.

Cerca
Categorie
Leggi tutto
Business
What Are the Benefits and Challenges of Remote Work?
Remote work has become increasingly popular, especially in the wake of the global pandemic. Many...
By Dacey Rankins 2025-01-29 17:02:10 0 6K
Телевидение
Инфо 24 - ТВ прямой эфир.
Телеканал «ИНФО 24» начал свое вещание в 2011 году.В 2022 году получил статус...
By Nikolai Pokryshkin 2022-11-03 19:53:04 0 22K
Жизненные вопросы
Красота по-американски. American Beauty. (1999)
Лестер Бернэм переживает кризис среднего возраста. Его не уважают и не ценят на работе, а от...
By Nikolai Pokryshkin 2022-12-23 11:50:19 0 24K
Business
Who Influenced the CEO's Career?
Understanding Mentors and Role Models Provides Context to the CEO's Values and Motivations A...
By Dacey Rankins 2025-07-01 13:14:38 0 659
Социальные проблемы
Большой побег. The Great Escape. (1963)
Американские, британские и канадские военнопленные осуществляют массовый побег из немецкого...
By Nikolai Pokryshkin 2023-02-21 11:42:09 0 23K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov