title: Function Values and How Are They Executed (How They Work)?
body: <p>I'm going through Eloquent JavaScript book and am on chapter 5 (Higher-Order Functions) currently. I'm doing good so far and have understood material clearly, but I've come to realize that I don't understand what function values are exactly and how they work. I do understand what functions are and am quite comfortable with the syntax of creating them using the function keyword as you would do in C for example.</p>
  
  <p>Assume the following code from the book:</p>
  
  <pre><code>function forEach(array, action) {
      for (var i = 0; i &lt; array.length; i++)
          action(array[i]);
  }
  
  var numbers = [1, 2, 3, 4, 5],
      sum = 0;
  
  forEach(numbers, function(number) {
      sum += number;
  });
  
  console.log(sum);
  </code></pre>
  
  <p>How does the forEach function, when called, determine what is the number? How does it extract number from the numbers array. I do understand that action argument in the definition of forEach function "hooks" the action to the element which is currently pointed by the for loop, but I interpret the code as follows:</p>
  
  <pre><code>function(number) {sum += number;}action(array[i])
  </code></pre>
  
  <p>which doesn't make much sense.</p>
  
  <p>If you could shed light on this issue I'd be more than thankful and also explain what the function value is exactly? How does it differ from function and/or function return value?</p>
  
  <p>Thank you.</p>