function statement vs function expression code example
Example 1: function expression vs function declaration
const functionExpression = function(width, height) {
return width * height;
};
console.log(functionExpression(3, 4));
function functionDeclaration(width,height){
return width * height;
};
console.log(functionDeclaration(3,4));
Example 2: function expression
const getRectArea = function(width, height) {
return width * height;
};
console.log(getRectArea(3, 4));
Example 3: javascript function expression
const mul = function(x, y){
return x * y;
};
console.log(mul(10, 20));