title: TS - Reduce an array of objects to an object
body: <p>I want to convert an array of objects to an object</p>
  <pre><code>var arrays = [
      {key:'k1',value:'v1'},
      {key:'k2',value:'v2'},
      {key:'k3',value:'v3'}
  ];
  </code></pre>
  <p>to</p>
  <pre><code>{k1: &quot;v1&quot;, k2: &quot;v2&quot;, k3: &quot;v3&quot;}
  </code></pre>
  <p>This works</p>
  <pre><code>const object: {[k: string]: any} = {};
  arrays.forEach((item) =&gt; { object[item.key] = item.value });
  </code></pre>
  <p>But I'd like how to do it using reduce.</p>
  <pre><code>const customData = arrays.reduce((obj, item) =&gt; (obj: Record&lt;string, any&gt;) =&gt; (obj[item.key] = item.value, obj), {});
  </code></pre>
  <p>returns</p>
  <pre><code>(obj) =&gt; (obj[item.key] = item.value) 
  </code></pre>
  <p>Thanks.</p>