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 |
Is javascript or python easier?
What is missing in my code? function numberTally(numList) { var evenTotal = 0; var oddTotal = 0; for (var i = 0; i <= numList.length; i++) { if i % 2 { // i is odd oddTotal += numList[i]; // or oddTotal = oddTotal + numList[i]; } else { // i is even evenTotal + numList[i]; } } alert(oddTotal); return evenTotal; }
Explain why "self" is needed instead of "this".
What is the best free ide?
how can count show data in grid view using java script
What is the use of isNaN function?
Name some of the built-in methods and the values returned by them.
Explain the difference between “==” and “===”?
Difference between the substr() and substring() in JavaScript?
How to write hello world on the web page?
What are anonymous functions in Javascript?
What is javascript tree shaking?