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
Ужасы
Семь. Se7en. (1995)
Детектив Уильям Сомерсет - ветеран уголовного розыска, мечтающий уйти на пенсию и уехать подальше...
Par Nikolai Pokryshkin 2022-11-14 12:13:12 0 36KB
Economics
What is renewable energy economics?
What Is Renewable Energy Economics? There is a moment, usually just before dawn, when a wind...
Par Leonard Pokrovski 2026-05-22 21:37:31 0 5KB
Алгоритмы
Как работают алгоритмы Tik Tok
Продвижение бизнеса в Tik Tok это уже необходимость.Tik Tok - это социальная сеть. Многие не...
Par Dmitry Novikov 2023-01-30 00:50:30 0 37KB
Marketing and Advertising
What Is PPC (Pay-Per-Click) Advertising?
Pay-per-click (PPC) advertising is one of the most widely used and effective forms of online...
Par Dacey Rankins 2026-01-28 16:02:28 0 5KB
Information Services
Information Services: The Backbone of the Digital Economy
In today’s increasingly connected world, information is one of the most valuable assets for...
Par Dacey Rankins 2024-11-12 14:42:15 0 14KB

BigMoney.VIP Powered by Hosting Pokrov