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

Difference between Client side JavaScript and Server side JavaScript?

1 Answers  


How can a Javascript code redirect the user to a different page?

0 Answers  


What is the difference between undefined and not defined in JavaScript?

0 Answers  


Explain javascript accessors ?

0 Answers  


What is context in javascript?

0 Answers  


What is a javascript code?

0 Answers  


List out all the falsifying tokens in Javascript?

0 Answers  


Can you explain about screen object?

0 Answers  


What is scope chain in javascript?

0 Answers  


Name some of the ways in which Type Conversion is possible?

0 Answers  


What are JavaScript types?

11 Answers   Infosys, Satyam,


How do you assign object properties?

3 Answers   Satyam,


Categories