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.

البحث
الأقسام
إقرأ المزيد
Business
How Do I Handle Negative Feedback?
Strategies to Receive and Respond to Criticism Positively and Productively Receiving negative...
بواسطة Dacey Rankins 2025-05-28 14:20:11 0 10كيلو بايت
Social Issues
97 Minutes. (2023)
A hijacked 767 will crash in just 97 minutes when its fuel runs out. Against the strong will of...
بواسطة Leonard Pokrovski 2023-06-15 20:31:06 0 41كيلو بايت
Business
How Can a Solopreneur Build a Strong Personal Brand?
In today’s competitive marketplace, building a strong personal brand is crucial for...
بواسطة Dacey Rankins 2025-02-12 15:41:41 0 16كيلو بايت
Philanthropy
Understanding Philanthropy: The Art of Giving Back
Understanding Philanthropy: The Art of Giving Back In a world often marked by division and...
بواسطة Leonard Pokrovski 2024-06-11 23:14:47 0 17كيلو بايت
Business
What Do You Like Most About Working for This Company?
During a job interview, one insightful question candidates often ask is: "What do you like most...
بواسطة Dacey Rankins 2025-06-24 15:32:48 0 7كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov