title: JavaScript: Pick old array by key and rename the key in new array
body: <p>I have an array of objects and I want to "pick" a new array from the value of the key <code>viewerId</code>. I also want to change the name of the <code>viewerId</code> key to <code>userId</code>. Here is what I have done with lodash:</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>const viewerList = [{
      "id": 1,
      "viewerId": 5,
      "status": true
    },
    {
      "id": 2,
      "viewerId": 8,
      "status": true
    },
    {
      "id": 3,
      "viewerId": 6,
      "status": true
    },
    {
      "id": 4,
      "viewerId": 9,
      "status": true
    }
  ]
  
  var result = []
  _.each(viewerList, (o) =&gt; {
    result.push(_.pick(o, 'viewerId'))
  })
  
  result = result.map(function(item) {
    return {
      userId: item.viewerId
    }
  });
  
  console.log(result)</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am doing this in two steps. Can this be optimized?</p>