title: index in function in javascript
body: <p>While attempt to read "secrets of the javascript Ninja"(ok, so perhaps I am not qualify to read this book just yet) but I see below code and I understand what code is doing but part I really don't understand is where function(index) is being called. Is index arbitrary terms or some sort of javascript to indicate generic index?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    function forEach(list,callback) {
      for (var n = 0; n &lt; list.length; n++) {
        callback.call(list[n],n);
      }
  }
    var weapons = ['shuriken','katana','nunchucks'];
    forEach(
      weapons,
      function(index){
          function
  
  ￼￼￼￼￼         assert(this == weapons [index],
               "Got the expected value of " + weapons [index]);
  } );
  &lt;/script&gt;
  </code></pre>