title: array reduce javascript typescript
body: <p>Just for my own culture.
  I have understood how works the reduce principle</p>
  
  <pre><code>var sumAll = function(...nums: number[]):void{
      var sum = nums.reduce((a, b) =&gt; a + b , 0);
  
      document.write("sum: " + sum + "&lt;br/&gt;");
  }
  sumAll(1,2,3,4,5);
  </code></pre>
  
  <p>It gives 15 because we start at 0.</p>
  
  <p>and 1+2= 3 first call -> 1+2 are replace by 3</p>
  
  <p>3+3=6 second call 3 -> 3
  +3 are replaced by 6 </p>
  
  <p>6+4 = 10 thrid call  -> 6+4 are replaced by 10</p>
  
  <p>10+5 = 15 fourth call -> 10 + 5 are replaced by the final result 15</p>
  
  <p>it's ok.</p>
  
  <p>but what's happen when I do </p>
  
  <pre><code>var sumAll = function(...nums: number[]):void{
      var sum = nums.reduce((a, b, c) =&gt; a + b +c , 0);
  
      document.write("sum: " + sum + "&lt;br/&gt;");
  }
  sumAll(1,2,3,4,5);
  </code></pre>
  
  <p>the result is 25 but i don't understand why...
  I guessed</p>
  
  <p>first call: 1+2+3 = 6 (1+2+3 are replaced by 6)</p>
  
  <p>second call 6+4+5 = 15 ( 6 +4 + 5 are replaced by 15 and it's the final result)</p>
  
  <p>but why the result gives 25?</p>
  
  <p>Thanks in advance;)</p>