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.

Suche
Kategorien
Mehr lesen
Marketing and Advertising
How Much Will Video Marketing Cost — and How Should You Budget for It?
Introduction Video marketing has become an essential part of modern brand strategy. Whether...
Von Dacey Rankins 2025-11-10 16:34:03 0 11KB
Personal Finance
What Is Compound Interest and How It Helps Your Savings Grow Over Time
What Is Compound Interest and How It Helps Your Savings Grow Over Time Compound interest is...
Von Leonard Pokrovski 2025-11-19 22:00:30 0 7KB
Business
Coaching is an effective process of personnel development
Coaching is an effective process of personnel development What is Coaching? This is...
Von Leonard Pokrovski 2024-08-11 16:20:25 0 22KB
Television
Charles Dayadharum. Live TV. USA.
The Jesus Live Network Television Broadcast. Channel 8. My Link
Von Nikolai Pokryshkin 2022-10-04 13:34:38 0 49KB
Marketing and Advertising
Social Media Strategy: How to Build a High-Impact Presence
Social media isn’t just about posting content — it’s about building trust,...
Von Dacey Rankins 2025-11-03 15:07:48 0 27KB

BigMoney.VIP Powered by Hosting Pokrov