JavaScript Map

0
12KB

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
What is the Best Business Structure for a Startup?
Starting a business is an exciting and challenging endeavor. One of the most important decisions...
Par Dacey Rankins 2025-04-10 14:44:35 0 10KB
Business
How Do I Write a Business Plan?
Writing a business plan is a crucial step for anyone starting or growing a business. It serves as...
Par Dacey Rankins 2025-04-30 12:48:39 0 12KB
Marketing and Advertising
How Do We Differentiate Our Brand in a Crowded B2B Market?
In today’s B2B landscape, the competition is fierce. Buyers are overwhelmed with messages...
Par Dacey Rankins 2025-09-22 15:30:12 0 9KB
Marketing and Advertising
How Long Does Marketing Take to Show Results?
Introduction: The Patience Problem in Marketing In the fast-paced world of modern business, one...
Par Dacey Rankins 2025-10-14 17:09:22 0 6KB
Pre-School
The Importance of Preschool: Laying the Foundation for Lifelong Learning
Preschool is often seen as the first formal experience for young children before they enter...
Par Dacey Rankins 2024-11-27 17:49:03 0 14KB

BigMoney.VIP Powered by Hosting Pokrov