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 |
List html dom mouse events?
Does spacing matter in javascript?
What Does JavaScript Void(0) Mean?
what is flux in javascript?
How to toggle display an html element?
What is a javascript code?
Will javascript be replaced?
Is client side front end?
Which built-in method removes the last element from an array and returns that element?
How do I use javascript to password-protect my web site?
What does break and continue statements do in javascript?
What is the instanceof operator in JavaScript?