JavaScript Map

0
12K

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.

Căutare
Categorii
Citeste mai mult
Business
What Are the Best Books for Startup Founders?
Starting a business is an exciting yet challenging journey, and as a startup founder, you're...
By Dacey Rankins 2025-04-03 14:54:40 0 8K
Finance
How to Get a Mortgage
How to Get a Mortgage Buying a home is one of the biggest financial decisions most people make...
By Leonard Pokrovski 2025-09-20 17:31:03 0 7K
Publications
Exploring the Vital Role of Publications: A Gateway to Knowledge
Exploring the Vital Role of Publications: A Gateway to Knowledge In the realm of academia,...
By Leonard Pokrovski 2024-05-25 00:19:18 0 28K
История
Куда ты идешь, Аида? Quo vadis, Aida? (2020)
Аида — переводчица при нидерландском контингенте войск ООН. В Сребренице живут её муж и...
By Nikolai Pokryshkin 2022-09-11 21:38:16 0 32K
Internet Broadcasts
The Rise of Internet Broadcasts: Transforming Media and Communication
The internet has revolutionized the way we communicate, access information, and entertain...
By Dacey Rankins 2024-12-09 14:04:38 0 10K

BigMoney.VIP Powered by Hosting Pokrov