title: Understanding Function Declaration Javascript
body: <p>I am trying to understand function declaration in Javascript in RXJS Library. I am trying to understand how the function is declared.</p>
  <p><a href="https://rxjs.dev/api/index/function/scan" rel="nofollow noreferrer">https://rxjs.dev/api/index/function/scan</a></p>
  <pre><code>scan&lt;V, A, S&gt;(accumulator: (acc: V | A | S, value: V, index: number) =&gt; A, seed?: S): OperatorFunction&lt;V, V | A&gt;
  </code></pre>
  <p>My understanding</p>
  <p>1.scan takes three arguments <code>&lt;V, A, S&gt;</code></p>
  <p>2.return <code>OperatorFunction&lt;V, V | A&gt;]</code></p>
  <p>3.Seed is optional <code>[ seed?: S ]</code></p>
  <p>but i am not able to understand what does below mean</p>
  <p><code>(accumulator: (acc: V | A | S, value: V, index: number) =&gt; A, seed?: S)</code></p>
  <p>Why do we need word</p>
  <p><code>accumulator:</code></p>
  <p>and what does below mean, why do we need an arrow function</p>
  <p><code>=&gt; A, seed?: S</code></p>
  <p>It should be declared like
  <code>scan&lt;V, A, S&gt;(acc: V | A | S, value: V, index: number)): OperatorFunction&lt;V, V | A&gt;</code></p>
  <p>Please throw some light.</p>