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
Economics
Why is free enterprise associated with democracy?
Why Is Free Enterprise Associated with Democracy? The Remarkable Relationship Between Economic...
Von Leonard Pokrovski 2026-06-03 01:13:49 0 2KB
Business
In Education, Events, and HR: “Was the Content Organized?” “How Often Does Your Supervisor Give Feedback?”
In settings like education, corporate events, and human resources, two essential drivers of...
Von Dacey Rankins 2025-07-25 14:12:29 0 7KB
Programming
Golang vs Java
Golang  Launched in 2011, Go or Golang is an open-source language from Google. Similar...
Von Jesse Thomas 2023-07-03 17:15:47 0 14KB
Decision Making and Problem Solving
How do businesses use behavioral economics?
How Do Businesses Use Behavioral Economics? The $8 Bottle of Wine A restaurant owner faced a...
Von Michael Pokrovski 2026-06-10 12:12:12 0 4KB
Science Fiction and Fantasy
Avengers: Endgame. (2019)
After the devastating events of Avengers: Infinity War (2018), the universe is in ruins. With the...
Von Leonard Pokrovski 2023-01-03 21:03:41 0 33KB

BigMoney.VIP Powered by Hosting Pokrov