From 07bbd7338f7c47331de651a347e1139f4a598443 Mon Sep 17 00:00:00 2001 From: Nicholas Lee Date: Fri, 17 Nov 2017 10:13:09 +0900 Subject: [PATCH] improve the answer about closure refernces https://github.com/getify/You-Dont-Know-JS/blob/master/scope%20%26%20closures/ch5.md --- front-end/interview-questions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index a3f1f52a..64bc41a7 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -714,7 +714,7 @@ As a personal habit, I never leave my variables undeclared or unassigned. I will ### What is a closure, and how/why would you use one? -A closure is the combination of a function and the lexical environment within which that function was declared. The word "lexical" refers to the fact that lexical scoping uses the location where a variable is declared within the source code to determine where that variable is available. Closures are functions that have access to the outer (enclosing) function's variables—scope chain even after the outer function has returned. +A closure is the combination of a function and the lexical environment within which that function was declared. The word "lexical" refers to the fact that lexical scoping uses the location where a variable is declared within the source code to determine where that variable is available. Closures are functions that have access to the outer (enclosing) function's variables—scope chain even after the outer function has returned. If we talk about closure, we should mention a function and a scope, because closure is a kind of relationship between function and scope, for example, "the foo() has a closure over the scope" **Why would you use one?**