Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

closures

Name: Anonymous 2011-11-07 17:48

this thread is dedicated to javascript's most important innovation: the concept of functions that capture their lexical environment

Name: Anonymous 2011-11-07 21:44


var arr = [];
for (var i = 0; i < 10; i++ ) {
  arr[i] = (function (i) {
    return function () {
      return i;
    };
  })(i)
}

beautiful!

i'd like to see your language do the same thing more elegantly!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List