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
Телевидение
"2-я Садовая" ТВ он лайн.
«2-я Садовая» – это воплощение и продолжение традиций саратовского...
By Nikolai Pokryshkin 2022-10-27 18:53:27 0 37K
Personal Development
How do I develop a growth mindset?
Developing a growth mindset is one of the most powerful shifts you can make for long-term...
By Michael Pokrovski 2026-02-04 23:45:53 0 6K
Human Resources
What Is the Selection Process in Personnel Management?
The selection process is one of the most crucial stages in personnel management. While...
By Dacey Rankins 2026-04-09 18:27:46 0 1K
Business
How do I highlight achievements without sounding boastful in my business biography?
Writing a business biography involves striking the right balance between showcasing your...
By Dacey Rankins 2025-01-08 13:57:07 0 18K
Business
What Should Be on the Agenda, and How Do I Share It?
Structuring and Distributing Focused Meeting Agendas A well-run meeting starts long before...
By Dacey Rankins 2025-08-01 11:03:18 0 8K

BigMoney.VIP Powered by Hosting Pokrov