javascript - How to convert Map keys to array?

Аватар автора
#short #javascript #dictionary #ecmascript-6 Lets say I have the following map: let myMap = new Map().set('a', 1).set('b', 2); And I want to obtain ['a', 'b'] based on the above. My current solution seems so long and horrible. let myMap = new Map().set('a', 1).set('b', 2); let keys = []; for (let key of myMap) keys.push(key); console.log(keys); There must be a better way, no?

0/0


0/0

0/0

0/0

0/0