Sunday, October 30, 2022

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps.
for example
step 1 - 
function add(a,b){return a+b;}
step 2-
add(3,4);
result 7

Javascript provides an approach to declare and execute the function immediately. Which is known as IIFE(Immediately Invoked Function Expression)

Example:
(
function add(x,y){
alert(x+y);
})();

No comments:

Post a Comment

JavaScript Functions as JavaScript Variables

In Javascript instead of declaring and executing a function in two different steps. for example step 1 -  function add(a,b){return a+b;} ste...