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
Social Issues
Operation Varsity Blues: The College Admissions Scandal. (2021)
Reenactments drive this documentary investigating the mastermind behind a scam to sneak the kids...
Von Leonard Pokrovski 2022-09-13 14:46:08 0 44KB
Human Resources
What Are Examples of Knowledge Capital?
In today’s knowledge-driven economy, organizations rely heavily on intangible assets to...
Von Dacey Rankins 2026-03-24 16:15:59 0 2KB
Marketing and Advertising
How Do You Measure the Success of a Community?
Community building is an art, but measuring whether your community is truly successful requires...
Von Dacey Rankins 2025-09-26 15:12:18 0 13KB
Business
How Can I Connect with Other Indie Hackers for Support and Collaboration?
Building a successful indie business can often feel like a lonely journey. As you work to develop...
Von Dacey Rankins 2025-02-17 16:45:14 0 17KB
Business
How Does the Build-Measure-Learn Feedback Loop Work?
The Build-Measure-Learn feedback loop is a core principle of the Lean Startup methodology,...
Von Dacey Rankins 2025-03-07 13:52:36 0 20KB

BigMoney.VIP Powered by Hosting Pokrov