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
Horror
Stowaway (2021)
A three-person crew on a mission to Mars faces an impossible choice when an unplanned passenger...
Von Leonard Pokrovski 2022-09-20 19:32:11 0 30KB
Financial Services
Building a foundation for retirement
Building a foundation for retirement Retirement can mean different things for different...
Von Mark Lorenzo 2023-05-24 19:00:14 0 21KB
Television
UN press briefings. Live TV. USA.
The UN Web TV Channel is available 24 hours a day with selected live programming of United...
Von Nikolai Pokryshkin 2022-10-12 19:01:24 0 29KB
Business
Is Your Boss Talking Too Much?
In the workplace, communication is critical—but it’s a two-way street. When one voice...
Von Dacey Rankins 2025-06-03 13:39:57 0 9KB
Marketing and Advertising
What Books or Biographies Are Written by Advertising Legends?
Advertising is an industry built on ideas, persuasion, and storytelling—so it is no...
Von Dacey Rankins 2026-01-07 14:32:02 0 2KB

BigMoney.VIP Powered by Hosting Pokrov