JavaScript Map

0
10χλμ.

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.

Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
История
Непрощённый. Unforgiven. (1992)
История Уильяма Мунни — бывшего хладнокровного убийцы, нашедшего в себе силы покончить с...
από Nikolai Pokryshkin 2023-02-13 13:10:57 0 25χλμ.
Cultures and Groups
Art in Culture: A Timeless Reflection of Society
Art has long been an essential element of human civilization, playing a profound role in shaping...
από Dacey Rankins 2025-01-22 14:28:16 0 9χλμ.
Социальные проблемы
История игрушек. Toy Story. (1995)
В спальне Энди его игрушки начинают жить своей жизнью, как только он выходит из комнаты. В день...
από Nikolai Pokryshkin 2022-12-31 11:10:19 1 23χλμ.
Business
The Top 20 Project Management Questions I Get Asked Most Often
Over the years of working in project management, one thing has become clear—whether I'm...
από Dacey Rankins 2025-05-19 14:44:28 0 6χλμ.
Financial Services
The structure of costs in the short run
Key points Looked at from a short-run perspective, a firm’s total costs can...
από Mark Lorenzo 2023-07-13 20:18:32 0 12χλμ.

BigMoney.VIP Powered by Hosting Pokrov