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 |
How do you implement Ajax using hide() function in JQuery?
How do you reverse a string in javascript?
How do you name a variable in javascript?
Name some of the Javascript frameworks?
what is the difference between window & document in javascript?
How to validate a form in javascript?
Expand BOM and explain it?
What value does prompt() return if the user clicked the cancel button?
Are there any training Institutions on iphone Automation testing?
What is the main difference between Client side JavaScript and and Server side Java Script?
How many days it will take to learn javascript?
What is the function of javascript?