Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is a “closure” in JavaScript? Provide an example



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

Post New Answer

More JavaScript Interview Questions

Explain the working of timers in javascript?

0 Answers  


What exactly does javascript do?

0 Answers  


e=1+x/!+x2/2!+x3/3!+.... in javascript

0 Answers  


How to trigger a postback on an updatepanel from javascript?

0 Answers  


What does _ mean in javascript?

0 Answers  


How to get height and width of different browser in Javascript?

0 Answers  


Which software is best for javascript?

0 Answers  


What does 3+4+"7" evaluate to?

0 Answers  


Why is javascript hoisting?

0 Answers  


How to create array in JavaScript?

0 Answers  


What does window.print() do in Javascript?

0 Answers  


How to Object.entries( ) In JavaScript ?

0 Answers  


Categories