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 |
Explain the working of timers in javascript?
What exactly does javascript do?
e=1+x/!+x2/2!+x3/3!+.... in javascript
How to trigger a postback on an updatepanel from javascript?
What does _ mean in javascript?
How to get height and width of different browser in Javascript?
Which software is best for javascript?
What does 3+4+"7" evaluate to?
Why is javascript hoisting?
How to create array in JavaScript?
What does window.print() do in Javascript?
How to Object.entries( ) In JavaScript ?