title: Javascript anonymous functions with parameters. Where are those parameters defined?
body: <p>I had a doubt about replacing some characters in a textbox using jQuery and I landed <a href="https://stackoverflow.com/questions/2391274/jquery-replace-text-in-val">in this question.</a> The accepted answer suggested something like this:</p>
  
  <pre><code>$("#mySelector").val(function(i, v) { //i, v... where they come from??
  return v.replace("#","Custom Text");
  });
  </code></pre>
  
  <p>That works fine but I still have the same doubt. Those parameters, <code>i</code> and <code>v</code>. Where do they come from and how they are filled with data? They are not declared anywhere. How do <code>i</code> and <code>v</code> in this case, has the data that I need?</p>
  
  <p><a href="https://stackoverflow.com/questions/21358027/how-are-input-parameters-filled-in-javascript-method-chains">These answers</a> talk about it, but it seems just an overcomplicated explanation for what should be, an easy thing to explain.</p>
  
  <p>So, the question is simple. How in the world those parameters in the anonymous function, get filled with data. Where do they come from if I didn't declare them anywhere?</p>