What is a “closure” in JavaScript? Provide an example
Answer / hrpatelsoft@gmail.com
var globalVar = "xyz";
(function outerFunc(outerArg) {
var outerVar = 'a';
(function innerFunc(innerArg) {
var innerVar = 'b';
console.log(
"outerArg = " + outerArg + "
" +
"innerArg = " + innerArg + "
" +
"outerVar = " + outerVar + "
" +
"innerVar = " + innerVar + "
" +
"globalVar = " + globalVar);
})(456);
})(123);
| Is This Answer Correct ? | 0 Yes | 0 No |
What is eval() in javascript?
What is are the types of the pop up box es available in javascript?
How use javascript html?
What is enum data type?
Is Exception handling possible in Javascript?
What does the instanceof operator do?
What is event bubbling in JavaScript?
How to getting values from cookies to set widgets?
show the date in textbox when we select item (items like-- today,yesterday,lastweek,lastmonth,lastyear) from dropdownlist using javascript?
How many types of functions JavaScript supports?
What is the role of javascript in a web page?
What is output of “20” + 20 + 20 and “20” + ( 20 + 20)? In javascript?