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.

Rechercher
Catégories
Lire la suite
Business
How Do Startup Founders Split Equity with Co-Founders?
Starting a business is an exciting yet challenging journey, and one of the most crucial decisions...
Par Dacey Rankins 2025-04-04 14:12:41 0 14KB
Home Automation
Home Automation
Home automation or domotics is building automation for a home, called a smart home or smart...
Par FWhoop Xelqua 2022-09-07 13:28:52 0 48KB
Programming
Display Data from Python to HTML
When making a web application, you're probably thinking if displaying data from Python to HTML is...
Par Jesse Thomas 2023-01-26 19:18:03 0 14KB
Business
What Makes a Good User Story?
In Agile product development, the user story is one of the most fundamental tools. It’s not...
Par Dacey Rankins 2025-08-25 18:43:18 0 8KB
Marketing and Advertising
What Is Display Remarketing? A Complete Guide to Banner and Network-Based Retargeting
In fact, most users browse, compare options, and leave before making a decision. Display...
Par Dacey Rankins 2026-02-12 20:32:04 0 3KB

BigMoney.VIP Powered by Hosting Pokrov