title: Which part of the code executes inner function?
body: <p>I came across this question in one of the online quizes. The solution I came up with was <em>function</em>. BUT, the console logs <em>number</em>.</p>
  
  <pre><code>var f = (
     function f(){return "1";},
     function g (){return 2;}
  )();
  console.log(typeof f);
  </code></pre>
  
  <p>My thinking was: <code>var f</code> becomes an IIFE, so <code>typeof f</code> should be a function.</p>
  
  <p>Now, apparently, <code>function g()</code> inside <code>var f</code> executes and returns its value to <code>var f</code>, so the console logs <em>number</em> (or 2, if I just log <code>f</code>).</p>
  
  <p>Questions:</p>
  
  <p>1.What is the explanation for <em>function <strong>comma</strong> anotherFunction</em>. This is not an object, and also not a variable declaration (like var x, y;)?</p>
  
  <p>2.Somehow the second function is the one that is being returned, but what part of the code is actually executing it? </p>
  
  <p>(I thought that <code>()</code> just before the <code>console.log</code> call is executing the outer <code>f</code> function (which should just define inner functions <code>f()</code> and <code>g()</code>, but not execute any of them ). The second one gets executed, so , obviously, I was wrong.</p>