title: Explanation of Following Javascript Code
body: <p>I am fairly new to js and I have been looking at the Mozilla Developer site. Under the functions section, I can't seem to grasp the following</p>
  
  <pre><code>function map(f,a) {
    var result = [], // Create a new Array
        i;
    for (i = 0; i != a.length; i++)
      result[i] = f(a[i]);
    return result;
  }
  </code></pre>
  
  <p>particulary, this line "result[i] = f(a[i]);"</p>
  
  <p>From Mozilla:
  Function expressions are convenient when passing a function as an argument to another function. The following example shows a map function being defined and then called with an anonymous function as its first parameter</p>
  
  <p>Can you help explain this?</p>
  
  <p>Here is a link for reference.
  <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions</a></p>