JavaScript Map

0
12كيلو بايت

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.

البحث
الأقسام
إقرأ المزيد
القصص
The History of Games: From Ancient Play to Digital Masterpieces
Games have been an integral part of human culture for thousands of years. From the earliest forms...
بواسطة Dacey Rankins 2024-11-25 14:35:28 0 10كيلو بايت
Medicine
Medication
Medication Lekárstvennyj...
بواسطة Leonard Pokrovski 2024-04-16 19:27:09 0 15كيلو بايت
Business
What Is Sales Territory Management?
Sales territory management is one of the most overlooked yet powerful levers in sales...
بواسطة Dacey Rankins 2025-12-19 19:38:24 0 1كيلو بايت
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...
بواسطة Dacey Rankins 2026-01-07 14:32:02 0 3كيلو بايت
Mental Health
Autism Spectrum: Misdiagnosis
There is a significant level of misdiagnosis of autism in neurodevelopmentally typical children;...
بواسطة Kelsey Rodriguez 2023-03-09 16:07:13 0 11كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov