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
Business
How Can Communication Style Be Adapted to Different Personalities?
In today’s diverse and dynamic workplace, one-size-fits-all communication rarely works....
Von Dacey Rankins 2025-08-05 14:59:07 0 8KB
Life Issues
The Kid. (1921)
The Tramp cares for an abandoned child, but events put their relationship in jeopardy. My Link
Von Leonard Pokrovski 2023-02-04 17:51:54 0 21KB
Marketing and Advertising
Press Releases: Common Mistakes to Avoid and How to Measure Their Effectiveness
A press release remains one of the most powerful tools in public relations and marketing,...
Von Dacey Rankins 2025-10-29 16:55:49 0 11KB
Finance
How Do I Stop Automatic Debit Payments from My Account?
How Do I Stop Automatic Debit Payments from My Account? Automatic debit payments are a...
Von Leonard Pokrovski 2025-10-04 22:05:45 0 9KB
Productivity
What is the best productivity method?
What Is the Best Productivity Method? There is no universally “best” productivity...
Von Michael Pokrovski 2026-02-23 21:01:45 0 642

BigMoney.VIP Powered by Hosting Pokrov