JavaScript Map

0
11كيلو بايت

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.

البحث
الأقسام
إقرأ المزيد
Personal Finance
What Is “Education Inflation” and How Should You Account for It?
What Is “Education Inflation” and How Should You Account for It? Will the cost next...
بواسطة Leonard Pokrovski 2025-11-03 22:56:32 0 800
التعليم
The Importance of Art Education: Cultivating Creativity and Critical Thinking
Art education is a vital component of a well-rounded academic curriculum. While subjects like...
بواسطة Dacey Rankins 2025-01-20 16:19:05 0 11كيلو بايت
Business
7 Common Conflict Styles That Show Up in Relationships, According to Experts
Conflict is a natural part of any relationship, whether romantic, familial, or professional....
بواسطة Dacey Rankins 2025-06-10 15:16:12 0 8كيلو بايت
Emulators
9 Best Android Emulators for PC and Mac
Why do I need an emulator? Android emulators allow you to run smartphone apps and games on your...
بواسطة FWhoop Xelqua 2022-10-03 16:50:33 0 34كيلو بايت
Business
What Is a Project Management Plan?
A Project Management Plan is a comprehensive, formal document that outlines how a project will be...
بواسطة Dacey Rankins 2025-05-15 14:34:45 0 7كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov