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.

Pesquisar
Categorias
Leia mais
Business
How to choose quality office supplies?
It wasn’t an expensive pen. But it was the only one within reach when a signature was...
Por Dacey Rankins 2026-05-05 19:54:47 0 2KB
Asia
Welcome to Asia!
The largest part of the world, washed by three oceans and accommodating 53 states, Asia on the...
Por FWhoop Xelqua 2022-09-13 14:44:49 0 36KB
Software
Unraveling the Science Behind Software: Bridging the Gap Between Logic and Creativity
Unraveling the Science Behind Software: Bridging the Gap Between Logic and Creativity In the...
Por Leonard Pokrovski 2024-05-27 22:10:35 0 21KB
Business
What Are the Best Small Business Loans or Grants Available?
Starting or expanding a small business often requires financial support. Fortunately, various...
Por Dacey Rankins 2025-03-14 16:10:16 0 17KB
Economics
Short-run vs long-run analysis
Short-Run vs Long-Run Analysis Economists often pretend that time is merely a neutral backdrop....
Por Leonard Pokrovski 2026-05-07 17:31:37 0 3KB

BigMoney.VIP Powered by Hosting Pokrov