Define closure.


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();  

Leave a Reply

Your email address will not be published. Required fields are marked *