title: Is callback function always a closure?
body: <p>In Javascript, callback function is always a closure? <strong>The inverse is not true [?] as you see bellow</strong>:</p>
  
  <pre><code>function makeFunc() {
    var name = "Mozilla";
    function displayName() {
      alert(name);
    }
    return displayName;
  };
  
  var myFunc = makeFunc();
  myFunc();
  </code></pre>
  
  <p>Where <code>myfunc</code> is a closure, and not a callback.</p>
  
  <blockquote>
    <p>Closures are functions that inherit variables from their enclosing environment. When you pass a
    function callback as an argument to another function that will do I/O, this callback function will
    be invoked later, and this function will — almost magically — remember the context in which it
    was declared, along with all the variables available in that context and any parent contexts. This
    powerful feature is at the heart of Node’s success.</p>
  </blockquote>
  
  <p>From other <a href="http://www.sitepoint.com/demystifying-javascript-closures-callbacks-iifes/" rel="nofollow">link</a>:</p>
  
  <blockquote>
    <p>Also, because callbacks behave as if they are actually placed inside
    that function, they are in practice closures: they can access the
    containing function’s variables and parameters, and even the variables
    from the global scope.</p>
  </blockquote>
  
  <p><a href="http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/" rel="nofollow">link</a></p>
  
  <blockquote>
    <p>When we pass a callback function as an
    argument to another function, the callback is executed at some point
    inside the containing function’s body just as if the callback were
    defined in the containing function. This means the callback is a
    closure. Read my post, Understand JavaScript Closures With Ease for
    more on closures. As we know, closures have access to the containing
    function’s scope, so the callback function can access the containing
    functions’ variables, and even the variables from the global scope.</p>
  </blockquote>