Sunday, 15 December 2019

JavaScript functional expresion

Functional expresion is function without name ex

Var squareIt=Function(a,b)
{
Return a*b

}

Var c=squareIt(4,5)

This will only called when we invoke it.

If we need immediate invocation then use 


Var c=(function (){

Var a=4;

Var b=5;

Return b*c;

}())

You may ask why we use when result is 20 only whel you can have a global value in place of a and b and can use it.

No comments:

Post a Comment