JavaScript Map

0
13KB

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.

Suche
Kategorien
Mehr lesen
Marketing and Advertising
How to Use Social Media Effectively for Marketing
Introduction: Why Social Media Is Every Business’s Stage In today’s digital economy,...
Von Dacey Rankins 2025-10-14 17:17:03 0 8KB
Business
How Do Product Managers Prioritize Features?
Feature prioritization is one of the most challenging tasks for product managers. With limited...
Von Dacey Rankins 2025-08-15 20:34:49 0 9KB
Business
How to avoid over-ordering supplies?
The storage room looked prepared for a minor apocalypse. Towering boxes of printer paper leaned...
Von Dacey Rankins 2026-05-07 00:47:23 0 2KB
Business
Is Affiliate Marketing Passive Income?
The phrase “passive income” has been stretched so aggressively online that it barely...
Von Dacey Rankins 2026-05-15 15:12:13 0 479
Marketing and Advertising
How Do I Choose the Right Market Research Method? (A Complete 2025 Guide)
Introduction: The Art of Choosing the Right Market Research Approach Market research is one of...
Von Dacey Rankins 2025-10-09 18:30:16 0 10KB

BigMoney.VIP Powered by Hosting Pokrov