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
Business
What Type of Business Should I Start?
Starting a business is an exciting venture, but choosing the right type can feel overwhelming....
Von Dacey Rankins 2025-02-06 15:01:46 0 12KB
Geld
How to Make Money Online
How to Make Money Online In today’s digital age, making money online has become more...
Von Leonard Pokrovski 2025-09-20 17:34:15 0 8KB
Computers
57 Best Computer Companies – Best Laptops
57 Best Computer Companies – Best Laptops • MICROSOFT Who doesn’t know...
Von Leonard Pokrovski 2024-03-20 22:10:58 0 40KB
Marketing and Advertising
Why Market Research Is Important: Key Benefits and Real-World Impact
Introduction: The Power of Knowing Before You Act In a world where competition is fierce and...
Von Dacey Rankins 2025-10-09 18:20:24 0 6KB
Business
How Do You Handle Rejections? Maintaining Professionalism and Empathy in Candidate Communication
Rejection is an inevitable part of the hiring process, but how it’s handled can...
Von Dacey Rankins 2025-06-25 12:50:42 0 8KB

BigMoney.VIP Powered by Hosting Pokrov