About 12,200,000 results
Open links in new tab
  1. function - How do JavaScript closures work? - Stack Overflow

    Sep 21, 2008 · A closure is a pairing of: A function and A reference to that function's outer scope (lexical environment) A lexical environment is part of every execution context (stack frame) and is a map …

  2. What is a practical use for a closure in JavaScript?

    Apr 28, 2010 · This is called a JavaScript closure. It makes it possible for a function to have " private " variables. The counter is protected by the scope of the anonymous function, and can only be …

  3. What exactly does "closure" refer to in JavaScript?

    Nov 26, 2009 · From JavaScript Closures Two one-sentence summaries: A closure is the local variables for a function - kept alive after the function has returned, or A closure is a stack-frame which is not …

  4. functional programming - What is a 'Closure'? - Stack Overflow

    Aug 31, 2008 · Closure is a feature in JavaScript where a function has access to its own scope variables, access to the outer function variables and access to the global variables.

  5. JavaScript closure inside loops – simple practical example

    Apr 15, 2009 · JavaScript closure inside loops – simple practical example Asked 16 years, 8 months ago Modified 2 years, 7 months ago Viewed 490k times

  6. JavaScript closures vs. anonymous functions - Stack Overflow

    Oct 17, 2012 · In JavaScript, the closure depends on lexical scoping (which is true in most C-languages). So, returning a function is mostly returning an anonymous/unnamed function.

  7. javascript - Accessing variables trapped by closure - Stack Overflow

    Variables within a closure aren't directly accessible from the outside by any means. However, closures within that closure that have the variable in scope can access them, and if you make those closures …

  8. javascript - How is a closure different from a callback ... - Stack ...

    Mar 5, 2009 · I asked a question about callbacks and arrived at another question (see comment). How is a closure different from a callback?

  9. Closures VS Classes in modern Javascript - Stack Overflow

    Mar 30, 2022 · 3 For closures which main goal it's to create another functions, I was wondering if in modern javascript, it's better to just use classes in modern javascript.

  10. javascript closure advantages? - Stack Overflow

    Jun 10, 2011 · 3 Closures are necessary in javascript due to the fact that most API's that require callback functions (for instance, an "onclick" function) do not provide other mechanisms to send …