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 eval() in javascript?

0 Answers  


What is are the types of the pop up box es available in javascript?

0 Answers  


How use javascript html?

0 Answers  


What is enum data type?

0 Answers  


Is Exception handling possible in Javascript?

0 Answers  


What does the instanceof operator do?

0 Answers  


What is event bubbling in JavaScript?

0 Answers  


How to getting values from cookies to set widgets?

0 Answers  


show the date in textbox when we select item (items like-- today,yesterday,lastweek,lastmonth,lastyear) from dropdownlist using javascript?

1 Answers  


How many types of functions JavaScript supports?

0 Answers  


What is the role of javascript in a web page?

0 Answers  


What is output of “20” + 20 + 20 and “20” + ( 20 + 20)? In javascript?

0 Answers  


Categories