title: Explain this JavaScript Recursion
body: <p>Explain this JavaScript Recursion what exactly happens when 0&lt;0 expression does eval for foo(3)?<br />
  function-foo returns console.log(&quot;test&quot;)<br />
  Is it that console.log() passed in return statement is unusual?<br />
  Is it that the array has two 0's for indices 3 and 4 because foo evals 0 twice because once i-1 reaches 1-1 recursive call should be foo(0) yes?<br />
  But continues but console.log is being called twice where foo() recursion call is hoisted between the two what difference does order make here?<br />
  I'm not making sense of why exactly these are results</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let ar = [];
  
  function foo(i) {
    if (i &lt; 0)
      return console.log("test");
  
    ar.push(i);
    console.log(i, Boolean(i&lt;0));
    foo(i - 1);
    ar.push(i);
    console.log(i, Boolean(i&lt;0));
  }
  
  foo(3)
  console.log('ar=', JSON.stringify( ar )) </code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0 }</code></pre>
  </div>
  </div>
  </p>