JavaScript Map

0
12كيلو بايت

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.

البحث
الأقسام
إقرأ المزيد
Life Issues
Rear Window. (1954)
A wheelchair-bound photographer spies on his neighbors from his Greenwich Village courtyard...
بواسطة Leonard Pokrovski 2022-12-09 19:36:34 0 30كيلو بايت
Home Health
How pet dogs and cats improve human physical and mental health
How pet dogs and cats improve human physical and mental health Pets bring joy, love...
بواسطة Leonard Pokrovski 2024-04-16 19:43:43 0 24كيلو بايت
Business
Coaching is an effective process of personnel development
Coaching is an effective process of personnel development What is Coaching? This is...
بواسطة Leonard Pokrovski 2024-08-11 16:20:25 0 20كيلو بايت
Business
10 Questions to Ask During a Job Interview to Find Out What Really Matters
Job interviews aren’t just about impressing potential employers—they're also a chance...
بواسطة Dacey Rankins 2025-06-12 14:54:18 0 14كيلو بايت
Personal Finance
How Often Should I Check My Credit Report?
How Often Should I Check My Credit Report? Your credit report is one of the most important...
بواسطة Leonard Pokrovski 2025-10-27 21:08:13 0 4كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov