title: ES6 function similar to map
body: <p>I came across on code which could be just like <code>map</code> function, but I don't understand all semantic. Look on this code:</p>
  
  <pre><code>const reduce = (reducer, accumulator) =&gt; arr =&gt; {
      const [first, ...rest] = arr
      return arr.length
       ? reduce(reducer, reducer(accumulator, first))(rest)
       : accumulator
  }
  
  reduce((accum, current) =&gt; [...accum, current * 2], [])([1, 2, 3]);
  </code></pre>
  
  <p>Could you explain me how this code works?</p>
  
  <ol>
  <li><p>why <code>...accum</code> is first arg but should be last and exactly <code>...accum</code> means in this example?</p></li>
  <li><p>why in <code>reduce</code> first reducer is invoke without any arguments?</p></li>
  </ol>