I was told that you can declare functions in JavaScript more than 1 way. ex.
// One way
function sqrt(x){
return x * x;
}
// Second way
var sqrtAlt = function (x){
return x * x;
}
- What is the difference between these two function declarations?
- The output is same but must have a reason to have two ways?
- I am also curious about how you would use them.
- Lastly, are there any other ways?
Thanks.