/jst_M&S_iterableKeys.js Secret
Created
October 6, 2021 12:12
This file contains hidden or 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment