- Why do we use closure?
- What is the advantage of closure?
- What are the disadvantages of using closures?
Why do we use closure?
Closures are important because they control what is and isn’t in scope in a particular function, along with which variables are shared between sibling functions in the same containing scope.
What is the advantage of closure?
Advantages of using Closures As we all know variables which we create inside function have local scope and only accessible in side the function not outside the function. Problem 1: Also variable defined inside the function created when we call function and destroyed which function close.
What are the disadvantages of using closures?
One drawback to using closures is that they can lead to over-consumption of memory, and possibly memory leaks if not handled properly.