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.

Поиск
Категории
Больше
Business
Secrets to Answering the World's Hardest Interview Questions
Some interview questions are designed not just to assess your skills—but to test your...
От Dacey Rankins 2025-06-23 13:33:35 0 5Кб
Business
What Skills Do I Need to Start a Startup?
Starting a startup is an exciting yet challenging journey. It requires a combination of skills...
От Dacey Rankins 2025-04-07 17:24:00 0 6Кб
Antiques
Antiques and Nobility
One of the most interesting definitions of antiques dates back to the end of the XIX century and...
От FWhoop Xelqua 2022-09-27 11:06:24 0 36Кб
Life Issues
Top Gun: Maverick. (2022)
After thirty years, Maverick is still pushing the envelope as a top naval aviator, but must...
От Leonard Pokrovski 2023-01-15 18:16:42 0 19Кб
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...
От Dacey Rankins 2024-11-27 17:49:03 0 11Кб

BigMoney.VIP Powered by Hosting Pokrov