How to get certain part of object array as a new array?
<p>I have an Object array:</p>

<pre><code>let products = [{ code: 'a', num: 1 }, { code: 'b', num: 2 }];
</code></pre>

<p>I want to get the <strong>codes</strong> array: <code>['a', 'b']</code>.</p>

<p>This is how I am doing now using <strong>lodash</strong>:</p>

<pre><code>let codes = [];
_.forEach(products, (product) =&gt; {
  codes.push(product.code);
});
</code></pre>

<p>Is there any smart way to do this?</p>