ES6 Map to Array Array.from



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);


 

 



xgqfrms