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.

Поиск
Категории
Больше
Business
What Are Common Execution Pitfalls in Startups?
Launching a startup is an exciting journey, but it’s also filled with hidden challenges...
От Dacey Rankins 2025-04-30 12:54:47 0 11Кб
Personal Finance
How Do I Check My Social Security Statement?
How Do I Check My Social Security Statement? Login Links and Steps for My Social Security...
От Leonard Pokrovski 2025-12-12 22:32:15 0 4Кб
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 9Кб
Financial Services
Measuring the size of the economy: gross domestic product
    Key points The size of a nation’s economy is...
От Mark Lorenzo 2023-03-27 19:35:59 0 14Кб
Business
What Are the Benefits of Joining a Startup Incubator?
Starting a business can be a challenging and isolating journey, but joining a startup incubator...
От Dacey Rankins 2025-04-24 16:54:05 0 16Кб

BigMoney.VIP Powered by Hosting Pokrov