JavaScript Map

0
13كيلو بايت

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
What Is a Work Breakdown Structure (WBS)?
A Work Breakdown Structure (WBS) is a key project management tool that breaks down the total...
بواسطة Dacey Rankins 2025-05-15 14:47:07 0 10كيلو بايت
Business
How Do Startup Founders Handle Failure?
Failure is an inevitable part of the startup journey, and while it can feel overwhelming, it...
بواسطة Dacey Rankins 2025-04-09 13:38:24 0 12كيلو بايت
Productivity
How to change my life through goal setting?
The Alchemy of Intent Most people treat goal setting as a shopping list for a better life....
بواسطة Michael Pokrovski 2026-05-06 19:42:42 0 2كيلو بايت
Finance
What Happens If I Get Counterfeit Currency?
What Happens If I Get Counterfeit Currency? Imagine this: you withdraw some cash from your bank,...
بواسطة Leonard Pokrovski 2025-10-20 16:35:17 0 9كيلو بايت
Business
What Are Goals in Google Analytics, and How Do I Create Them?
Google Analytics is more than just a traffic counter. It’s a tool designed to help you...
بواسطة Dacey Rankins 2025-08-30 00:48:39 0 11كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov