Skip to main content
9 events
when toggle format what by license comment
May 23, 2017 at 12:38 history edited CommunityBot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Nov 29, 2016 at 4:54 vote accept Michał Perłakowski
Nov 28, 2016 at 18:11 comment added user4639281 Though i disagree with your assessment that my version being a simplified version of your version, which is a simplified version of the original, somehow exludes my version from being a simplification of the original. If anything, it may be an over-simplification of the original. But i dont believe that it is technically incorrect to say it is a simplified version of the original
Nov 28, 2016 at 17:59 comment added user4639281 After reading my previous comment I realize that I may not have fully explained my point. While I don't believe that the differences between the two code blocks are relevant to the topic, I would be fine with your "correct" version in the edit.
Nov 28, 2016 at 17:04 comment added user4639281 "as answers to the original question, they are very different" I think we're going to have agree to disagree here, because I believe that the arguments in my previous comment negate this point. As far as making it a closure canonical, that would be simplifying it to the point of actually changing the meaning, as it would no longer be about callbacks, which is what I believe is bringing googlers to the question.
Nov 28, 2016 at 16:59 comment added Ilmari Karonen @TinyGiant: I agree that both versions do use closures to capture variables from an outer scope (although it should be noted that, with appropriate argument ordering, the latter version could be trivially rewritten to use .bind() instead). However, that is where the similarities end, and I would say that, as answers to the original question, they are very different. In any case, if your goal was to turn this answer into a canonical explanation of how JS closures work, note that we already have a pretty good canonical Q&A for that.
Nov 28, 2016 at 16:56 comment added user4639281 I do understand your position though, and am grateful that you gave me the courtesy of explaining your position instead of just stating it. Up voting because of this, not because of agreement
Nov 28, 2016 at 16:52 comment added user4639281 I argue that it is the same while being the most simplified version of the same concept. The important concept here is not factory functions, it is the fact that function statements create new lexical environments, and lexical environments inherit variable definitions from their outer environment reference. Hence, it is the most simplified version of the same code, with as little code as possible, requiring the least amount of supplementary information to understand for future viewers.
Nov 28, 2016 at 15:40 history answered Ilmari Karonen CC BY-SA 3.0