A function (often anonymous) bound to the referencing environment in its original lexical scope in such a way that it will still have access to that environment (its variables and other references) if executed outside that scope.

learn more… | top users | synonyms

5
votes
1answer
80 views

Closures in C#, necessary or not?

I've written JavaScript for a while, but lately I've been writing a lot of C#. I wanted to write a method that could take the column name of a DataTable and return ...
2
votes
2answers
124 views

Deeper abstracting of code into functions

I created a quiz using the module pattern. My code is as follows: ...
2
votes
1answer
131 views

Is my JavaScript OOP style correct?

I have done the following code for testing a web-service. Is my style correct for using OOP in JavaScript? ...
0
votes
1answer
79 views

JavaScript binding loss with setTimeout

My current task is to extend some JavaScript of a framework we are using. A pop-up should slide in, instead of just appear in the middle of the window. So I have overridden one of the framework's ...
2
votes
1answer
122 views

Correctly dealing with closures and modularity in Javascript

The code below is designed to deal with this situation: There is a Battle environment with Characters; these Characters obviously have certain characteristics and abilities, and they need to be ...
1
vote
3answers
200 views

Cleanest way to close over a counter in CoffeeScript

I haven't spent too much time with CoffeeScript and am trying to have a simple counter: ...
2
votes
1answer
104 views

Better way to avoid trapping vars in a closure's scope?

I have a quandary with regard to exactly how the JavaScript scope chain works in a particular situation, and despite my searching and reading I am still mainly working on assumptions. I was wondering ...
3
votes
2answers
431 views

JavaScript closure: code trivia to keep the event handler separate

Note: This was originally posted at SO, and as per the recommendation moving to this form. In my effort to learn JS on the backdrop of SVG development, I got lot of help from SO so far. The answer ...