JavaScript Map

0
12K

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.

Cerca
Categorie
Leggi tutto
Marketing and Advertising
What Is the Personal Life Story of Famous Advertisers?
Advertising history is often told through campaigns, agencies, and awards, but behind every...
By Dacey Rankins 2026-01-08 12:23:45 0 2K
Marketing and Advertising
What Should a Telemarketing Campaign Cost — and How Do You Budget It?
Introduction Telemarketing remains one of the most direct and measurable forms of customer...
By Dacey Rankins 2025-11-06 17:52:45 0 3K
Политика
Фэнтезийный мир на смену фантастике.
«В ФЭНТЕЗИЙНОМ ЖАНРЕ НЕТ НИ ДЕМОКРАТИИ, НИ ПРОГРЕССА — ЭТО БУДУЩЕЕ КАК...
By Sergey Sokolov 2023-01-24 15:27:10 0 34K
Business
What Is Growth Hacking?
In today’s fast-paced business environment, traditional marketing and growth strategies...
By Dacey Rankins 2025-09-04 13:28:39 0 4K
Financial Services
Your guide to key tax terms
1. Gross and taxable income Gross income is your total income over the course of the year....
By Mark Lorenzo 2023-05-31 19:27:37 0 13K

BigMoney.VIP Powered by Hosting Pokrov