CLOSURES 5

      5th Day                                                                                        See the source image

  • Hey Guys Welcome to my 5th day of Blog writing, I'm last year student from Shiva ji University, Kolhapur. This post has been posted for beginners and professionals both and new post will have to be updated on Every Saturday & Sunday.

  • HEY GUYS,WHAT DO YOU UNDERSTAND ABOUT  CLOSURES IN JS?
  • It means a closure can access variables and arguments of its outer function even after the function has finished.
  • Closure means, A function exist inside the another function. 
  • For Example , Syntax: var V= (function ( ) {      } ) ( ); This is the function.
  • Here we taking function inside another function like 
              
                  var math=   (function ( ) 
                    {       
         function Add ( ) {} //  function inside another function

                  function Substract ( ) {} // function inside another function

                  function Multiplication ( ) {} //  function inside another function

           } ) ( );
                            This concept is known as Closures. For Example

                      

       Explanation:
       So friends in above example, we have taken a function inside another function:
       var Math=(function ( ) { }) ( ); 
       Its inside we have taken another function which will be private like: 
       function _Add(num1,num2) { return num1+num2}
       Here Public function is : return {  Add: _Add  }
       var output= Math.Add(1,2) ,It is Developer client which is invoke my method.
        Output:
          

                                                           Thank You...


ليست هناك تعليقات:

إرسال تعليق