closure vs non-closure vs static

Edit on GitHub

asdf

Setup

var createClosure = function() {
    var a = 'hi';
    return function() {
        alert(a);
    };
}

var createNonClosure = function() {
    return function() {
        alert('hi');
    };
}

var callStatic = function() {
alert('hi');
}

Tests

  • closure

    createClosure()()
  • non-closure

    createNonClosure()()
  • static

    callStatic()