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
const obj = {}; | |
function test() { | |
return 1; | |
} | |
obj[test] = 123; | |
console.log(obj); | |
// "function test() {↵ return 1;↵}" : 123 |
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
const obj = { | |
0: 0, | |
z: 3, | |
'$': 6, | |
b: 4, | |
1: 6, | |
4: 1 | |
}; | |
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
const myMap = new Map(); | |
myMap | |
.set(1, 11) | |
.set(2, 22); | |
const iterator = myMap.values(); | |
for (let key of iterator) { | |
console.log(key); |
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
const myMap = new Map(); | |
myMap | |
.set(1, 11) | |
.set(2, 22); | |
const iterator = myMap.keys(); | |
for (let key of iterator) { | |
console.log(key); |
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
const myMap = new Map(); | |
myMap | |
.set(1, 11) | |
.set(2, 22); | |
const iterator = myMap.entries(); | |
for (let item of iterator) { | |
console.log(item); |
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
const myMap = new Map([[1, 11], [2, 22]]); | |
myMap.forEach((val, key, map) => { | |
console.log(val, key, map); | |
}); | |
// 11, 1, myMap | |
// 22, 2, myMap |
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
const myMap = new Map([[1, 11], [2, 22]]); | |
console.log(myMap.has(3)); // false | |
console.log(myMap.has(2)); // true |
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
const myMap = new Map(); | |
console.log(myMap.size); // 0 |
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
const myMap = new Map([[1, 11], [2, 22]]); | |
myMap.clear(); |
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
const myMap = new Map([[1, 11]]); | |
console.log(myMap.delete(1)); //true |