JavaScript Map

0
11K

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
School Time
The Importance of School Time for Kids: Learning, Growth, and Routine
School time is a pivotal part of every child’s life. It’s not just about academics;...
Por Dacey Rankins 2024-12-04 14:48:01 0 11K
Business
What Is Personal Development and Why Is It Important?
In today’s fast-paced world, personal development has become more than a...
Por Dacey Rankins 2025-09-05 15:46:47 0 3K
Business
What daily habits do successful founders have?
Success in the startup world rarely happens by accident. Behind every thriving founder is a set...
Por Dacey Rankins 2025-04-14 13:37:20 0 9K
Mental Health
ADHD: Controversy
ADHD, its diagnosis, and its treatment have been controversial since the 1970s. The controversies...
Por Kelsey Rodriguez 2023-05-09 17:30:57 0 11K
Financial Services
Building a foundation for retirement
Building a foundation for retirement Retirement can mean different things for different...
Por Mark Lorenzo 2023-05-24 19:00:14 0 20K

BigMoney.VIP Powered by Hosting Pokrov