Closures:- Since a nested function is a closure, this means that a nested function can “inherit” the arguments and variables of its containing function. In other words, the inner function contains the scope of the outer function. The closures can contain multiple scopes; they recursively contain the scope of the functions containing it. This is…