JavaScript Map

0
11KB

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.

Pesquisar
Categorias
Leia mais
Nature and Science
Good Will Hunting. (1997)
Will Hunting, a janitor at M.I.T., has a gift for mathematics, but needs help from a psychologist...
Por Leonard Pokrovski 2023-01-06 16:02:13 0 25KB
Organizations
UNESCO
WHAT IS UNESCO?UNESCO is an agency of the United Nations Educational, Scientific and Cultural...
Por FWhoop Xelqua 2023-07-08 19:27:39 0 22KB
Personal Finance
Can I Repair My Credit on My Own?
Can I Repair My Credit on My Own? Yes, you can dispute inaccuracies, negotiate with creditors,...
Por Leonard Pokrovski 2025-10-24 11:13:56 0 155
Business
Interaction with contractors — how to improve work with a programmer
In general, is it worth trying to improve this interaction with developers at all? Why should the...
Por Dacey Rankins 2024-09-18 16:35:51 0 14KB
Business
How Can I Encourage Others to Give Me Feedback?
Creating Environments Where Open and Honest Feedback Is Welcomed and Valued Feedback is a...
Por Dacey Rankins 2025-05-28 14:23:33 0 9KB

BigMoney.VIP Powered by Hosting Pokrov