Friday, 17 March 2017

What is self executive function in Jquery

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()

3 comments:

  1. "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
  2. • 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