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 the difference between client side javascript and server side javascript.
What is an object in javascript, give an example?
How do you implement Ajax using hide() function in JQuery?
How generic objects can be created?
What is the use of document object?
How to set a html document's background color?
What does ecma stand for?
Is java is a fully object object oriented language?
What does the term sticky session mean in a web-farm scenario?
Is a hash table an array?
What is a callback url?
How much time it will take to learn javascript?