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.

Поиск
Категории
Больше
Business
How Do I Use User Behavior Analysis in Marketing, Product Development, or UX Design?
User behavior analysis (UBA) is the practice of studying how people interact with a product,...
От Dacey Rankins 2025-08-22 19:23:32 0 6Кб
Marketing and Advertising
How to Measure the Success of Your Email Campaigns
Introduction Email marketing is one of the most effective ways to reach your audience, build...
От Dacey Rankins 2025-10-03 20:39:09 0 1Кб
Научная фантастика и фэнтези
Тёмный рыцарь: Возрождение легенды. The Dark Knight Rises. (2012)
Восемь лет назад Бэтмен растворился в ночи, превратившись из героя в беглеца. Приняв на себя вину...
От Nikolai Pokryshkin 2022-12-25 10:15:19 0 26Кб
Marketing and Advertising
What Is Guerrilla Marketing? Definition, Core Principles, and Modern Applications
Introduction Marketing has always been about grabbing attention — but in today’s...
От Dacey Rankins 2025-10-07 14:54:22 0 1Кб
Business
20 Customer Feedback Questions: A Curated List to Understand Customer Needs and Improve User Experience
Gathering customer feedback is essential for any business aiming to improve products, services,...
От Dacey Rankins 2025-05-29 17:52:17 0 11Кб

BigMoney.VIP Powered by Hosting Pokrov