This is very important to know that how can we use our methods or functions as the parameter of other function or method. Following example shows that the use of function or method as the parameter of other method or function.
Example 1: ( Callback function with parameter )
Following is the function need to pass as a parameter,
Example 1: ( Callback function with parameter )
Following is the function need to pass as a parameter,
funcion fun1()
{
alert("Funtion needs to be pass");
}
Following is the function, in which we need to pass the above function as a parameter,
funcion fun2(fun1CallBack)
{
fun1CallBack();
}
Following is the way to call the fun2() by passing fun1(),
fun2(fun1);
Example 2: ( Callback function with parameter )
Following example shows how to use our callback function has parameter
Following is the function need to pass as a parameter,
funcion fun1(name)
{
alert("You have entered " + name);
}
Following is the function, in which we need to pass the above function as a parameter,
funcion fun2(fun1CallBack)
{
fun1CallBack();
}
Following is the way to call the fun2() by passing fun1(),
fun2(fun1("Jhon"));
No comments:
Post a Comment