In JavaScript, we need closures when a variable which is defined outside the scope in reference is accessed from some inner scope.
var num = 10;
function sum()
{
document.writeln(num+num);
}
sum();
In JavaScript, we need closures when a variable which is defined outside the scope in reference is accessed from some inner scope.
var num = 10;
function sum()
{
document.writeln(num+num);
}
sum();