JavaScript Map

0
6Кб

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.

Поиск
Категории
Больше
Television
Fox 13 Salt Lake City. Live TV. USA.
Fox 13 (KSTU), is a Fox-affiliated television station located in Salt Lake City, Utah, United...
От Nikolai Pokryshkin 2022-10-15 11:08:18 0 26Кб
Business
How Social PR Works
The values that brands convey affect consumer choices. They like to buy products from socially...
От Dacey Rankins 2024-09-09 16:47:08 0 7Кб
Financial Services
Command-and-control regulation
Key points Command-and-control regulation sets specific limits for pollution...
От Mark Lorenzo 2023-07-21 19:23:46 0 9Кб
Wholesale Trade
Understanding Wholesale Trade: Key Insights and Its Role in the Economy
Wholesale trade is a fundamental part of the global supply chain and plays a pivotal role in the...
От Dacey Rankins 2024-11-25 14:14:38 0 4Кб
Travel
Named the most visited attractions in the world
The authoritative publication Travel + Leisure has published a list of the main tourist...
От FWhoop Xelqua 2023-01-03 14:47:15 0 16Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov