JavaScript Map

0
13كيلو بايت

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.

البحث
الأقسام
إقرأ المزيد
Economics
How Is Econometrics Applied in Research?
How Is Econometrics Applied in Research? Econometrics is a cornerstone of modern empirical...
بواسطة Leonard Pokrovski 2026-03-25 07:17:16 0 5كيلو بايت
Productivity
How do I improve overall well-being?
How Do I Improve Overall Well-Being? Overall well-being is a broad concept that extends far...
بواسطة Michael Pokrovski 2026-03-31 03:13:32 0 3كيلو بايت
Marketing and Advertising
How Do I Improve User Acquisition Conversion Rates?
Improving user acquisition conversion rates is one of the fastest ways to scale growth without...
بواسطة Dacey Rankins 2026-02-27 18:29:23 0 6كيلو بايت
Science Fiction and Fantasy
The Lord of the Rings: The Two Towers. (2002)
The continuing quest of Frodo and the Fellowship to destroy the One Ring. Frodo and Sam discover...
بواسطة Leonard Pokrovski 2022-11-11 17:38:19 0 28كيلو بايت
Emulators
Emulators: Bridging the Gap Between Past and Present in Technology
Emulators have become an essential tool in modern technology, enabling users to run software and...
بواسطة Dacey Rankins 2024-11-08 17:00:06 0 15كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov