Introduction
Enclosing scope helps a function remember variables from the function that contains it. This lets you use those variables inside the smaller function without passing them again.
When you want a small function inside another function to use some variables from the bigger function.
When you want to keep some data private inside a function but still use it in smaller helper functions.
When you want to organize your code by putting related functions inside each other.
When you want to create a function that remembers some settings or values from where it was created.