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

    Sep 21, 2008 · How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not …

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

    Aug 31, 2008 · Closures Whenever we have a function defined inside another function, the inner function has access to the variables declared in the outer function. Closures are best …

  3. 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 …

  4. javascript - Closure memory leak of unused variables - Stack …

    This basically includes all free variables the function could access (from what I understood of lostechies, javascript closures explained). Here the first issue arises: this should mean all …

  5. What underlies the `var self = this` JavaScript idiom?

    25 As others have explained, var self = this; allows code in a closure to refer back to the parent scope. However, it's now 2018 and ES6 is widely supported by all major web browsers. The …

  6. Javascript - difference between namespace vs. closure?

    Apr 27, 2012 · In Javascript, what's the difference between a namespace and a closure? They seem very similar to me. EDIT Specifically, this article discusses namespaces and closures, …

  7. javascript - variable calling function and calling function directly ...

    Oct 31, 2019 · Thanks for explaining in advance. 4/Nov: @DavidFleeman: Am I correct in my understand to first question (I read all 3 links, plus JavaScript Closures 101: What is a …

  8. JavaScript closures vs. anonymous functions - Stack Overflow

    Oct 17, 2012 · Editor's Note: All functions in JavaScript are closures as explained in this post. However we are only interested in identifying a subset of these functions which are interesting …

  9. javascript - What is 'Currying'? - Stack Overflow

    add(3)(4); // returns 7 var add3 = add(3); // returns a function add3(4); // returns 7 The first statement returns 7, like the add(3, 4) statement. The second statement defines a new …

  10. closures - What is the purpose of a self executing function in ...

    The statement " It’s about defining and executing a function all at once. " is wrong. Javascript code is first parsed in its entirety, then executed. Code can't be selectively executed before …