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 developers create advertising
Everything is stableSince real estate is not a cheap commodity, its advertising, as a rule, is...
Von Dacey Rankins 2024-09-13 19:32:27 0 14KB
Business
What ethical practices should I follow as a content creator?
As a content creator, you have a unique influence over your audience, and with that influence...
Von Dacey Rankins 2025-02-21 15:17:02 0 9KB
Business
Am I Prepared to Handle the Challenges of Running a Business?
Starting and running a business is an exciting and rewarding endeavor, but it’s also one of...
Von Dacey Rankins 2025-02-07 16:17:33 0 18KB
Business
Sales leads: types and methods of attraction
What does it mean? Sales leads are users who visited the website, visited the company's page on...
Von Dacey Rankins 2024-09-13 19:07:34 0 14KB
Business
Do I Need to Know How to Code?
When new tools like Microsoft Fabric enter the analytics and business intelligence world, one of...
Von Dacey Rankins 2025-09-02 15:31:16 0 3KB

BigMoney.VIP Powered by Hosting Pokrov