title: Convert array to object in JavaScript
body: <p>I'd like to convert an array into an object using one of the properties as key.</p>
  
  <p>For instance:</p>
  
  <pre><code>var stations = [ { name: 'A Coruna', ds100: 'OECSC' }, ... ];
  </code></pre>
  
  <p>I'd like to get <code>stationByDs100</code>:</p>
  
  <pre><code>{ 'OECSC': { name: 'A Coruna', ds100: 'OECSC' }, ... }
  </code></pre>
  
  <p>At the moment I do it as follows:</p>
  
  <pre><code>var stationByDs100 = {};
  stations.forEach(station =&gt; stationByDs100[station.ds100] = station);
  </code></pre>
  
  <p>I'm looking for a better way to accomplish this - is it possible with a one-liner without explicit variable declaration?</p>
  
  <p>For instance in Java 8 this could have accomplished with streams and collectors in one line like:</p>
  
  <pre><code>Map&lt;String, Station&gt; stationByDs100 = stations.stream()
      .collect(toMap(Station::getDs100, identity()));
  </code></pre>
  
  <p>So I was thinking maybe there's a similar way in JS.</p>
  
  <p>I'm using Node.js so OK to use the latest JS/ES features Node.js supports.</p>
  
  <p>I've browsed through a rougly dozen existing answers but they mostly use older JS/ES versions and suggest even longer solutions.</p>