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

What is the difference between client side javascript and server side javascript.

0 Answers  


What is an object in javascript, give an example?

0 Answers  


How do you implement Ajax using hide() function in JQuery?

2 Answers   QuinStreet,


How generic objects can be created?

0 Answers  


What is the use of document object?

0 Answers  


How to set a html document's background color?

0 Answers  


What does ecma stand for?

0 Answers  


Is java is a fully object object oriented language?

2 Answers  


What does the term sticky session mean in a web-farm scenario?

0 Answers  


Is a hash table an array?

0 Answers  


What is a callback url?

0 Answers  


How much time it will take to learn javascript?

0 Answers  


Categories