728x90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Iterable keys | |
// importance: 5 | |
// We’d like to get an array of map.keys() in a variable and then apply array-specific methods to it, e.g. .push. | |
// But that doesn’t work: | |
let map = new Map(); | |
map.set("name", "John"); | |
let keys = Array.from(map.keys()); | |
// Error: keys.push is not a function | |
keys.push("more"); | |
console.log(keys); |
'Algorithm > JavaScript(Node.js)' 카테고리의 다른 글
The Modern JS Tutorial: WeakMap and WeakSet: store read dates (0) | 2021.10.20 |
---|---|
The Modern JS Tutorial: WeakMap and WeakSet: Store "unread" flags (0) | 2021.10.20 |
The Modern JS Tutorial: Map and Set: filter anagrams (0) | 2021.10.06 |
The Modern JS Tutorial: Map and Set: filter unique array members (0) | 2021.10.06 |
The Modern JS Tutorial: array-methods: Create keyed object from array (0) | 2021.09.23 |