JavaScript Map

0
10كيلو بايت

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.

البحث
الأقسام
إقرأ المزيد
Alternative Medicine
Alternative Medicine: Exploring Holistic Approaches to Health and Wellness
Alternative medicine, also known as complementary or integrative medicine, refers to a wide...
بواسطة Dacey Rankins 2024-11-21 16:01:27 0 12كيلو بايت
Business
How Transparent Are Startup CEOs with Their Teams?
Transparency is more than a leadership buzzword—it’s a defining trait of effective...
بواسطة Dacey Rankins 2025-05-02 15:04:20 0 7كيلو بايت
Business
What role does leadership play in crisis management?
In times of crisis, the effectiveness of an organization’s response largely depends on the...
بواسطة Dacey Rankins 2025-01-17 16:52:39 0 8كيلو بايت
Business
What Practices Work Best to Motivate Teams?
One of the most common—and essential—questions managers ask themselves and others...
بواسطة Dacey Rankins 2025-07-17 14:33:02 0 3كيلو بايت
Business
When Can I Expect to Hear Back?
One of the most common and anxiety-inducing questions from candidates during interviews is,...
بواسطة Dacey Rankins 2025-08-07 17:37:26 0 3كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov