title: JavaScript - callback() vs callback
body: <p>Mostly working with Java so when I came across this <a href="http://callbackhell.com" rel="nofollow noreferrer">code</a>:</p>
  
  <pre><code>document.querySelector('form').onsubmit = formSubmit
  
  function formSubmit (submitEvent) {
    var name = document.querySelector('input').value
    request({
      uri: "http://example.com/upload",
      body: name,
      method: "POST"
    }, postResponse)
  }
  
  function postResponse (err, response, body) {
    var statusMessage = document.querySelector('.status')
    if (err) return statusMessage.value = err
    statusMessage.value = body
  }
  </code></pre>
  
  <p>Question is why are we using <strong>postResponse</strong> in formSubmit  when the function is <strong>postResponse (err, response, body)</strong>. When we are using <strong>postResponse</strong> how does it know which parameters are <strong>err, response and body</strong>?   </p>
  
  <p>Thanks.</p>