title: How does the _.invoke method work in Lodash?
body: <h1>Background</h1>
  
  <p>From the documentation about the <a href="https://lodash.com/docs#invoke" rel="noreferrer">invoke</a> method, I read:</p>
  
  <blockquote>
    <p>Invokes the method named by methodName on each element in collection, returning an array of the results of each invoked method</p>
  </blockquote>
  
  <p>Thus, I assumed that the following code would be synonymous, but this is not the case:</p>
  
  <pre><code>_.map(items, function(item) {
      return _.omit(item, 'fieldName');
  })
  
  _.invoke(items, _.omit, 'fieldName');
  </code></pre>
  
  <p>In this case, the <code>invoke</code> method produces an array of strings, while the map method returns an array of items with <code>fieldName</code> removed from each item.</p>
  
  <h2>Questions</h2>
  
  <ul>
  <li>How can one use the <code>invoke</code> method to achieve the same result as the <code>map</code> function?</li>
  <li>Why did <code>invoke</code> return the array of strings in this particular situation?</li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var items = [{id:1, name:'foo'}, 
               {id:2, name:'bar'}, 
               {id:3, name:'baz'}, 
               {id:4, name:'qux'}];
  
  console.log(
      _.invoke(items, _.omit, 'id')
  );
  
  console.log(
      _.map(items, function(item) {
          return _.omit(item, 'id');
      })
  );</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://getfirebug.com/firebug-lite-debug.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.3.1/lodash.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>