Objecy.keys().map() VS Array.map() : <p>can you give me an argument why approach A is better than approach B.</p>

<p>Approach A:</p>

<pre><code>const transformCompanyOptions = (companies: Array&lt;{id: string, name: string}&gt;, selectedId: string) =&gt; {
  return companies.map(key =&gt; {
    return {
      value: key.id,
      label: key.name,
      checked: key.id === selectedId
    }
  })
};
</code></pre>

<p>Approach B:</p>

<pre><code>const transformCompanyOptions = (companies: Array&lt;{id: string, name: string}&gt;, selectedId: string) =&gt; {
 const ret = Object.keys(companies).map((key) =&gt; {
    const newCompany = {};
    newCompany['value'] = companies[key].id;
    newCompany['label'] = companies[key].name;
    if (companies[key].id === selectedId) {
      newCompany['checked'] = true;
    }
    return newCompany;
  });
  return ret;
};
</code></pre>

<p><strong>Thank you</strong></p>
