How to convert Map keys to array?
<p>Lets say I have the following map:</p>
<pre><code>let myMap = new Map().set('a', 1).set('b', 2);
</code></pre>
<p>And I want to obtain <code>['a', 'b']</code> based on the above. My current solution seems so long and horrible.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let myMap = new Map().set('a', 1).set('b', 2);
let keys = [];
for (let key of myMap)
  keys.push(key);
console.log(keys);</code></pre>
</div>
</div>
</p>
<p>There must be a better way, no?</p>