๐Map
๐ง under construction
Last updated
Was this helpful?
๐ง under construction
Last updated
Was this helpful?
Was this helpful?
breadcrumb ๐ง
้็ถ Object ่ Map ้ฝๆฏ JS ็จไพๅฏฆ็พ Dictionary ็ๆนๆณ๏ผไฝๅฎๅๅญๅจๅบๆฌ็ไธๅ้ปใ
โ use [...map] to convert into Array.
โ for(const [key, value] of map){...}
โ for(const key of map.keys()){...}
โ does not implement .
โ not directly iterable using .
โญ can use to iterate over enumerable properties.
keys
can be any value (including functions, objects, or any primitive).
must be either or .
โ
number of items in a Map
โ no such property
// Array => Map
const map = new Map([['key1', 'value1'], ['key2', 'value2']])
// Map => Array<[Key, Value]>
[...map] // [['key1', 'value1'], ['key2', 'value2']]
โ for(const value of map.values()){...}
โ map.forEach((value, key) => {...})