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.

Rechercher
Catégories
Lire la suite
Marketing and Advertising
What Is the Difference Between PPC and SEO?
Pay-per-click (PPC) advertising and search engine optimization (SEO) are two of the most...
Par Dacey Rankins 2026-02-04 17:36:36 0 2KB
Business
How Long Does an M&A Deal Typically Take to Complete?
Mergers and acquisitions (M&A) are among the most complex and influential decisions a company...
Par Dacey Rankins 2025-11-27 17:17:48 0 8KB
Productivity
How do I set boundaries between work and personal life?
How Do I Set Boundaries Between Work and Personal Life? In an increasingly connected world, the...
Par Michael Pokrovski 2026-03-26 23:49:18 0 9KB
Central America
Interesting Central American Countries / Cities
Ranking of Central American countries by interestingness Due to the fact that I spent as...
Par FWhoop Xelqua 2023-01-08 16:38:34 0 27KB
Economics
What determines the demand for a currency?
What Determines the Demand for a Currency? The demand for a currency refers to the amount of...
Par Leonard Pokrovski 2026-08-13 20:45:23 0 5KB

BigMoney.VIP Powered by Hosting Pokrov