Self executive function-
It is a unnamed anonymous function that will be executed automatically when execution reached at (); Actually, jquery is a interpreted and dynamic language and jquery code is executed line by line so when execution reached at line (); It will be automatically fired.
Synatx -
(function(){
-------
-----
})();
Example:
var example = (function() {
var privateVariable = 'privateVariable';
function privateMethod() {
return 1;
}
return {
publicVariable: 'publicValue',
publicMethod: function() {
//return privateMethod();
}
};
}());
calling : example.publicMethod()
It is a unnamed anonymous function that will be executed automatically when execution reached at (); Actually, jquery is a interpreted and dynamic language and jquery code is executed line by line so when execution reached at line (); It will be automatically fired.
Synatx -
(function(){
-------
-----
})();
Example:
var example = (function() {
var privateVariable = 'privateVariable';
function privateMethod() {
return 1;
}
return {
publicVariable: 'publicValue',
publicMethod: function() {
//return privateMethod();
}
};
}());
calling : example.publicMethod()
"I very much enjoyed this article.Nice article thanks for given this information. i hope it useful to many pepole.php jobs in hyderabad.
ReplyDelete"
Thanks raghu konda
ReplyDelete• Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training Hyderabad
ReplyDelete