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.

Поиск
Категории
Больше
Music
12 Cloud Drift: 4 Hours of Soothing Ambient Music with Sunlit Skies
Here’s a blog draft for you: 4 Hours of Soothing Ambient Music with Sunlit Skies 🌤️...
От Gpykin 2025-08-23 21:59:02 0 19Кб
Мероприятия
The Thrilling World of Sports Events: Where Passion and Performance Collide
Sports events are more than just competitions; they are spectacles of human achievement, passion,...
От Dacey Rankins 2024-06-21 17:15:58 0 19Кб
Business
Which Books/Documentaries Are Best for Learning About This Leader’s Biography?
Books and documentaries bring a leader’s story to life, offering deeper understanding...
От Dacey Rankins 2025-08-13 21:15:50 0 5Кб
Personal Finance
What is income-driven repayment (IDR)? Plan types, eligibility, and how payments are calculated
What is income-driven repayment (IDR)? Plan types, eligibility, and how payments are calculated...
От Leonard Pokrovski 2025-12-16 21:03:59 0 2Кб
Marketing and Advertising
What Are the 4 Ps of Marketing? A Complete Guide to the Marketing Mix
Introduction: Why Every Marketer Needs to Master the 4 Ps Whether you’re running a...
От Dacey Rankins 2025-10-13 18:02:28 0 2Кб

BigMoney.VIP Powered by Hosting Pokrov