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.

Rechercher
Catégories
Lire la suite
Business
How Do I Market My Business on a Low Budget?
Marketing is essential for growing a business, but not every entrepreneur has a big budget for...
Par Dacey Rankins 2025-03-14 16:12:04 0 16KB
Productivity
How do I balance work and family life?
How Do I Balance Work and Family Life? Balancing work and family life is one of the most...
Par Michael Pokrovski 2026-03-26 23:57:08 0 10KB
Business
How Accurate Should Our Forecasts Be?
Forecasting is an essential part of business planning, helping organizations make informed...
Par Dacey Rankins 2025-01-10 14:18:36 0 32KB
Business
What Does the Hiring Process Look Like? / What Are the Next Steps?
Understanding the hiring process is a top priority for candidates during interviews. It helps...
Par Dacey Rankins 2025-08-07 17:36:13 0 15KB
Personal Finance
What Are the Tax Benefits of Owning a Home?
What Are the Tax Benefits of Owning a Home? Owning a home is often described as part of the...
Par Leonard Pokrovski 2025-12-23 19:56:00 0 8KB

BigMoney.VIP Powered by Hosting Pokrov