Immediately invoke function with argument:- JavaScript



In the previous example, we called the anonymous function without any argument. But in this function we are passed two(a, b) arugments.

Code:-

  • <!DOCTYPE html> 
    1. <html> 
    2.  
    3. <head> 
    4.  <meta name="viewport" content="width=device-width, initial-scale=1"> 
    5.  
    6.  <script> 
    7.   (function(a, b) 
    8.   { 
    9.    alert("a is : " + a); 
    10.    alert("b is : " + b); 
    11.   })(30, 60); 
    12.  </script> 
    13.  
    14. </head> 
    15.  
    16. <body> 
    17.  
    18. </body> 
    19.  
    20. </html>
    Immediately invoke function with argument:- JavaScript Immediately invoke function with argument:- JavaScript Reviewed by Network security on November 13, 2019 Rating: 5

    No comments:

    Useful Information

    Powered by Blogger.