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

List html dom mouse events?

0 Answers  


Does spacing matter in javascript?

0 Answers  


What Does JavaScript Void(0) Mean?

0 Answers  


what is flux in javascript?

0 Answers  


How to toggle display an html element?

0 Answers  


What is a javascript code?

0 Answers  


Will javascript be replaced?

0 Answers  


Is client side front end?

0 Answers  


Which built-in method removes the last element from an array and returns that element?

0 Answers  


How do I use javascript to password-protect my web site?

0 Answers  


What does break and continue statements do in javascript?

0 Answers  


What is the instanceof operator in JavaScript?

0 Answers  


Categories