title: Passing arguments in anonymous functions in JavaScript
body: <p>Sometimes I see JavaScript that is written with an argument provided that already has a set value or is an object with methods.  Take this jQuery example for instance:</p>
  
  <pre><code>$(".selector").children().each(function(i) {
      console.log(i);
  });
  </code></pre>
  
  <p>When logging <code>i</code>, you would get the value of whatever <code>i</code> is in that iteration when looking at the selectors children in the jQuery <code>each</code> method.</p>
  
  <p>Take this Node.js example:</p>
  
  <pre><code>http.createServer(function(request, response) {
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.write("Hello World");
      response.end();
  }).listen(8888);
  </code></pre>
  
  <p>You can see here that <code>request</code> and <code>response</code> are being passed and they contain their own methods that can be acted on.</p>
  
  <p>To me, this looks like were passing a function to the <code>createServer</code> function with two arguments that have methods already attached to them.</p>
  
  <p>My question is a multipart one:</p>
  
  <ol>
  <li>Where do these arguments come from?  </li>
  <li>If these are just anon functions, how do they receive arguments that can be acted on like other functions?</li>
  <li>How do I create functions that can take my own arguments like this??  </li>
  <li>Does this use the power of closures??</li>
  </ol>