title: Javascript differences in the expense of function calls under similar conditions
body: <p>I've been grappling over the results of two jsperf's I recently put together and trying to understand the impact of one over the other. Both address the invocation of a function vs doing something inline. </p>
  
  <p>The first jsperf if simple: <a href="http://jsperf.com/bool-exp-vs-func-call" rel="nofollow">http://jsperf.com/bool-exp-vs-func-call</a></p>
  
  <p>In the first case we loop and call a function which evaluates a boolean epxression which is randomly rotated after each call. In the second case we loop and but we evaluate the same boolean expression in the loop directly. </p>
  
  <p>The performance difference here is pretty small in chrome. My last run was 601 (inline) vs 555 (function). Not something I would lose sleep over.</p>
  
  <p>But then there is the curious case of looping which I put into this jsperf: <a href="http://jsperf.com/array-traversal-loop-vs-foreach/6" rel="nofollow">http://jsperf.com/array-traversal-loop-vs-foreach/6</a></p>
  
  <p>Here I'm only interested in comparing case 1 - which is a raw for loop vs the 3rd case which is 'own foreach'. In case 1 we loop N times and do our work (simply stating the variable). In case 2 we loop N times and call a function to do our work.</p>
  
  <p>But here, the performance difference is pretty massive. 1,717,348 (inline) vs 214,878 (function).</p>
  
  <p>What am I missing?</p>