News for hackers. Stuff that matters.
Re:JavaScript's world domination by chubot on Wednesday March 25, 2015 @12:48AM (#9261352)

    #!/usr/bin/node

    function main() {
      var a = 1;
      console.log(a);
    
      // named closure
      function foo() {
        a = a + 1;
      }
    
      foo();
      console.log(a);
    
      // anonymous closure
      (function() {
        a = a + 1;
      })();
    
      console.log(a);
    }
    main();
Re:JavaScript's world domination by kaoD on Wednesday March 25, 2015 @07:40AM (#9262261)
I'll emphasize GPs words:

> There is no such thing as an "anonymous closure". There are only anonymous functions which may or may not create a closure.

Which is exactly what you did: calling an anonymous function which happens to create a closure over variable `a`.