JavaScript Map

0
12KB

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.

Suche
Kategorien
Mehr lesen
Marketing and Advertising
What Is Facebook Pixel and How Does It Work?
The Facebook Pixel—now officially called the Meta Pixel—is one of the most important...
Von Dacey Rankins 2026-01-22 19:34:45 0 20
Spiele
Games labeled "PS5 Pro Enhanced" will offer a stable 60 FPS, increased resolution, or improved ray tracing
Games labeled "PS5 Pro Enhanced" will offer a stable 60 FPS, increased resolution, or improved...
Von Leonard Pokrovski 2024-04-01 20:57:51 0 23KB
Programming
Python http.cookiejar
The http.cookiejar module defines classes for automatic handling of HTTP cookies. It is...
Von Jesse Thomas 2023-04-06 21:02:37 0 11KB
Business
How Can I Improve My Mindset?
Your mindset is the lens through which you view the world. It influences how you respond to...
Von Dacey Rankins 2025-09-08 08:01:19 0 7KB
Personal Finance
What Percentage of My Salary Should Go to Savings? Budgeting Frameworks Explained
What Percentage of My Salary Should Go to Savings? Budgeting Frameworks Explained Figuring out...
Von Leonard Pokrovski 2025-12-05 19:43:56 0 2KB

BigMoney.VIP Powered by Hosting Pokrov