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
Investing
The Pros and Cons of Investing: Weighing Your Options
Investing is a powerful tool for building wealth and achieving financial goals. However, it comes...
Von Dacey Rankins 2024-10-09 17:31:39 0 20KB
Economics
What Is a Recession?
What Is a Recession? A recession is a significant, widespread, and prolonged decline in economic...
Von Leonard Pokrovski 2026-03-31 07:53:51 0 5KB
Sport
Rocky. (1976)
A small-time Philadelphia boxer gets a supremely rare chance to fight the world heavyweight...
Von Leonard Pokrovski 2023-04-16 19:46:10 0 33KB
Marketing and Advertising
What Types of Facebook Ads Are There?
Facebook offers a wide range of ad formats designed to support different business goals,...
Von Dacey Rankins 2026-01-21 19:24:58 0 4KB
Marketing and Advertising
What Are the Core Components of a Marketing Strategy?
Introduction A strong marketing strategy is the backbone of successful business growth. It...
Von Dacey Rankins 2025-10-15 19:03:40 0 7KB

BigMoney.VIP Powered by Hosting Pokrov