title: How to use map() to call method common to list of objects?
body: <p><strong>TL;DR:</strong> Basically, I'm trying to use <code>Array.prototype.map()</code> to call a method common to a list of context objects. </p>
  
  <p>Say I have some code like this:</p>
  
  <pre><code>a.doSomething();
  b.doSomething();
  c.doSomething();
  d.doSomething();
  e.doSomething();
  ...
  </code></pre>
  
  <p>This is overly verbose. I want to be able to shorten this code up to something like this</p>
  
  <pre><code>[a, b, c, d, e].map(doSomething);
  </code></pre>
  
  <p>because I don't want to have to use a <code>for</code> loop.</p>
  
  <p>How would I be able to do this with the native <code>map</code> function in JS, <strong>without</strong> any external libraries?</p>
  
  <p>Thank you in advance! If this post is too long, I will happily edit it. Just scream at me.</p>
  
  <p><strong>Related questions:</strong> </p>
  
  <p><a href="https://stackoverflow.com/questions/17997959/how-to-use-map-to-call-class-methods-on-a-list-of-objects">How to use map() to call class methods on a list of objects</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2682012/how-to-call-same-method-for-a-list-of-objects">How to call same method for a list of objects?</a></p>
  
  <p><em>I didn't use the info in the related questions because Python and JS use different paradigms and I don't have assurance they'll work the same. If I'm wrong here, please don't hesitate to burn me at the stake.</em></p>
  
  <p><strong>Extra info, disregard if you'd like:</strong> </p>
  
  <p>I've <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="nofollow noreferrer">already</a> <a href="http://bit.ly/1I1RjZo" rel="nofollow noreferrer">RTFM</a>, and the wording and examples suggest I can't do the above with <code>map</code>. The MDN docs describe <code>map</code> as "calling a provided function <strong><em>on</em></strong> every element in an array", while the MSDN docs say it "calls a function <strong><em>on</em></strong> each element of an array, and returns an array." I'm not trying to call a method <em>on</em> an array, I'm trying to call a method <em>from</em> several context objects. If this is not possible, is there a native polyfill?</p>
  
  <p>I'm using this in a game, so speed is my main concern. If there is a more optimal way to code this, please let me know!</p>