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.

Поиск
Категории
Больше
Billiards
The benefits of playing Billiards
Health benefits of billiardsThe game of billiards has a positive impact both on the formation of...
От FWhoop Xelqua 2022-12-29 12:53:53 0 20Кб
Social Issues
No Country for Old Men. (2007)
Violence and mayhem ensue after a hunter stumbles upon a drug deal gone wrong and more than two...
От Leonard Pokrovski 2023-02-23 18:42:03 0 24Кб
Business
How Can I Encourage Active Participation During Meetings?
Strategies to Build Engagement, Inclusivity, and Ownership Meetings are meant to drive...
От Dacey Rankins 2025-05-30 14:55:53 0 16Кб
Marketing and Advertising
What Is Dynamic Remarketing? A Complete Guide to Personalized Advertising at Scale
Modern consumers expect personalized experiences. They want to see products, services, and offers...
От Dacey Rankins 2026-02-12 00:04:47 0 7Кб
Business
Who Supports Me? Am I Setting Healthy Boundaries?
Life is not a solo journey. No matter how independent we are, our growth and happiness are shaped...
От Dacey Rankins 2025-09-08 08:08:04 0 6Кб

BigMoney.VIP Powered by Hosting Pokrov