JavaScript Map

0
11KB

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.

Rechercher
Catégories
Lire la suite
Social Issues
There Will Be Blood. (2007)
A story of family, religion, hatred, oil and madness, focusing on a turn-of-the-century...
Par Leonard Pokrovski 2023-02-13 15:11:23 0 18KB
Business
What Are Common Challenges Startups Face?
Starting a new business is an exciting venture, but it’s also filled with numerous...
Par Dacey Rankins 2025-03-04 14:34:12 0 10KB
Социальные проблемы
Подозрительные лица. The Usual Suspects. (1995)
Если есть преступление, есть и мотив. Если проводится опознание, то по крайней мере есть один...
Par Nikolai Pokryshkin 2022-12-01 21:43:39 0 26KB
Speech Technology
Computer Speech Technology
Computer speech technology, often referred to as speech recognition or speech synthesis,...
Par Dacey Rankins 2024-11-01 13:59:54 0 14KB
Wrestling
The Thrill and Tradition of Sports Wrestling
Sports wrestling, a centuries-old discipline, continues to captivate athletes and audiences alike...
Par Dacey Rankins 2024-07-15 16:41:11 0 16KB

BigMoney.VIP Powered by Hosting Pokrov