ES6 Map to Array

时间:2023-03-09 19:46:53
ES6 Map to Array

ES6 Map to Array

function differentSymbolsNaive(str) {
// write code here.
const map = new Map();
const arr = Array.from(str);
for (const item of arr) {
if(!map.has(item)) {
map.set(item, item);
}
}
return [...map].length;
// return [...map.keys()].length;
}

Array.from


const map = new Map().set('a', 1).set('b', 2); const array = Array.from(map, ([name, value]) => ({ name, value })); console.log(array);

https://*.com/questions/56795743/how-to-convert-map-to-array-of-object

https://*.com/questions/35341696/how-to-convert-map-keys-to-array/35341828

https://*.com/questions/8763125/get-array-of-objects-keys

refs


ES6 Map to Array

xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!