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.

Поиск
Категории
Больше
Financial Services
The economics of pollution
Key Points Economic production can cause environmental damage. This tradeoff...
От Mark Lorenzo 2023-07-20 18:29:02 0 16Кб
Middle East
Middle East
The Middle East is a region centered in Western Asia. In Russian-language literature, the term...
От FWhoop Xelqua 2023-02-22 17:11:04 0 21Кб
Antiques and Collectibles
A Guide to Shopping for Antiques and Collectibles: Tips for Finding Timeless Treasures
Shopping for antiques and collectibles is a thrilling journey that combines history, artistry,...
От Dacey Rankins 2024-11-29 15:08:02 0 11Кб
Financial Services
Supply and its determinants
The law of supply The law of supply states that there is a positive...
От Mark Lorenzo 2023-02-24 17:17:03 0 13Кб
Business
How Many Slides Should a Pitch Deck Have?
One of the most common questions among founders, entrepreneurs, and professionals preparing...
От Dacey Rankins 2025-12-03 15:54:41 0 3Кб

BigMoney.VIP Powered by Hosting Pokrov