How to call a function that return another function in JavaScript ?

The task is to call a function that returns another function with the help of JavaScript is called a Currying function, a function with numerous arguments that can be converted into a series of nesting functions with the help of the currying method.
We’re going to discuss a few techniques.
Approach:
- First, call the first function-1.
- Define a function-2 inside function-1.
- Return the call to function-2 from function-1.
Example 1: In this example, “from function 2” is returned from the fun2 which is finally returned by fun1.
Javascript
| functionfun1() {    functionfun2() {        return"From function fun2";    }    returnfun2();}functionGFG_Fun() {    console.log(fun1());}GFG_Fun() | 
Output
From function fun2
Example 2: In this example, “Alert from fun2” is returned from the fun2 along with an alert, Returned value is finally returned by fun1.
Javascript
| functionfun1() {    functionfun2() {        console.log("From function fun2");        return"Alert from fun2 ";    }    returnfun2();}functionGFG_Fun() {    console.log(fun1());}GFG_Fun() | 
Output
From function fun2 Alert from fun2
 
				 
					


