What is a closure in JavaScript?
-
A
A method that closes a browser window
-
B
A function that has access to its outer scope's variables even after the outer function has returned
-
C
A way to terminate a loop early
-
D
An error-handling mechanism similar to try/catch