JavaScript Map

0
13K

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.

Site içinde arama yapın
Kategoriler
Read More
Decision Making and Problem Solving
How do I build better habits?
You sit staring at a broken streak tracker on your phone screen, watching a long line of...
By Michael Pokrovski 2026-07-24 10:27:05 0 2K
Economics
Are we in a recession right now?
Are We in a Recession Right Now? The modern citizen learns about recessions the same way...
By Leonard Pokrovski 2026-05-12 17:57:21 0 10K
Productivity
How do I manage multiple projects at once?
Managing multiple projects at the same time is a common challenge in modern work environments....
By Michael Pokrovski 2026-03-07 00:30:48 0 28K
Business
How Can I Apply to a Startup Incubator?
For many entrepreneurs, joining a startup incubator can be a pivotal step in turning a promising...
By Dacey Rankins 2025-04-24 17:00:06 0 11K
Business
What Are Their Marketing Strategies?
When analyzing competitors, one of the most valuable insights you can uncover is their marketing...
By Dacey Rankins 2025-09-29 20:00:23 0 11K

BigMoney.VIP Powered by Hosting Pokrov