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.

البحث
الأقسام
إقرأ المزيد
Economics
What Is the Difference Between Commerce and Trade?
What Is the Difference Between Commerce and Trade? In everyday conversation, people often use...
بواسطة Leonard Pokrovski 2026-02-13 19:10:16 0 4كيلو بايت
Mental Health
ADHD: Pathophysiology
Current models of ADHD suggest that it is associated with functional impairments in some of the...
بواسطة Kelsey Rodriguez 2023-04-10 18:57:55 0 11كيلو بايت
Marketing and Advertising
The Future of Storytelling in the Digital and AI Era
Introduction Storytelling has always evolved with technology. From campfire tales to printed...
بواسطة Dacey Rankins 2025-11-05 14:32:53 0 4كيلو بايت
Business
How Does the Company Support Employee Growth and Development?
In today’s dynamic and competitive job market, organizations that prioritize employee...
بواسطة Dacey Rankins 2025-06-11 13:23:23 0 11كيلو بايت
Human Resources
What is Performance Management in HR?
In any organization, achieving business goals depends heavily on how well employees perform their...
بواسطة Dacey Rankins 2026-03-19 18:32:43 0 712

BigMoney.VIP Powered by Hosting Pokrov