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
Business
What Happens If a Payment Fails?
Most membership organizations celebrate successful payments. They should. Every completed...
Von Dacey Rankins 2026-06-26 03:10:31 0 1KB
Marketing and Advertising
How Do We Differentiate Our Brand in a Crowded B2B Market?
The B2B market is more competitive than ever. With new entrants, commoditization of technology,...
Von Dacey Rankins 2025-09-20 15:49:05 0 18KB
Marketing and Advertising
Can Billboard Ads Include QR Codes or URLs?
As billboard advertising evolves alongside digital marketing, advertisers increasingly look for...
Von Dacey Rankins 2026-01-15 18:00:00 0 8KB
Business
What Exactly Is a Partnership (Business-Legal Definition)?
Introduction: Understanding Business Partnerships In the world of business, collaboration can...
Von Dacey Rankins 2025-11-28 14:50:48 0 6KB
Television
KFSM - 5 News Live TV. Arkansas, USA.
KFSM-TV is the CBS-affiliated television station for the Arkansas River Valley and Northwest...
Von Nikolai Pokryshkin 2022-10-25 09:45:43 0 33KB

BigMoney.VIP Powered by Hosting Pokrov