JavaScript Map

0
12KB

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.

Suche
Kategorien
Mehr lesen
Жизненные вопросы
Золотая лихорадка. The Gold Rush. (1925)
История о злоключениях извечного любимца публики, маленького бродяги, который на этот раз...
Von Nikolai Pokryshkin 2023-03-17 15:22:14 0 26KB
Business
Why is the Issue of Sustainability Important for Development?
Sustainability is one of the most pressing issues facing global development today. As the world...
Von Dacey Rankins 2025-02-03 16:08:42 0 15KB
Finance
Are All Bank Accounts Insured by the FDIC?
Are All Bank Accounts Insured by the FDIC? When people deposit their money into a bank, one of...
Von Leonard Pokrovski 2025-10-02 21:57:52 0 12KB
Marketing and Advertising
When Can Telemarketers Legally Call Me? Understanding Hours, Time Zones, and Exceptions
Introduction Telemarketing is a powerful tool for businesses to reach customers, but the timing...
Von Dacey Rankins 2025-11-05 14:46:18 0 5KB
Life Issues
The Wizard of Oz. (1939)
Young Dorothy Gale and her dog Toto are swept away by a tornado from their Kansas farm to the...
Von Leonard Pokrovski 2023-06-20 20:34:15 0 38KB

BigMoney.VIP Powered by Hosting Pokrov