JavaScript Map

0
11KB

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
Programming
Functions and Classes in a function
Today, I've learned that you can apparently put functions and class methods inside of a function...
Por Jesse Thomas 2023-01-31 19:52:59 0 11KB
Flowers
The Best Flowers to Shop For: A Guide to Choosing the Perfect Blooms
Whether you’re looking to brighten your home, celebrate a special occasion, or simply enjoy...
Por Dacey Rankins 2024-11-29 15:05:28 0 9KB
Ужасы
Время. Old. (2021)
Отправившись в отпуск на тропический остров, семья с двумя детьми решает последовать совету...
Por Nikolai Pokryshkin 2022-09-11 22:13:06 0 40KB
Programming
Differences Between For Loop And forEach Loop in JavaScript
for loop forEach loop Generic type of loop and can be used in a variety of scenarios....
Por Jesse Thomas 2023-05-29 20:48:24 0 11KB
Business
What role does storytelling play in a business biography?
torytelling is one of the most powerful tools in writing a business biography. A well-crafted...
Por Dacey Rankins 2025-01-08 13:58:22 0 12KB

BigMoney.VIP Powered by Hosting Pokrov