There are several ways you can write a function in javaScript.
1. first of all a simple and popular way “Function Statement”.
function func_name ([param],[param],……[param] ){
// statement
}
2. Second way is “function Operator”
var func_name = function ([param],[param],……[param] ){
//statement
}
3. Another way is “function constructor”
var func_name = new function ([param],[param],……[param] ){
//statement
}
In function operator , you can assign the function to another variable but in function statement You can not do this.
In function operator, you can use array of function . as Example…
var fn = array[ function (x ) {return x;} , function (x ) {return x*x ;},function (x ) {return x*X*x;}
]
for fn[0](5) , output is 5
for fn[1](5) , output is 25
for fn[2](5) , output is 125