Problem Statement
Which of the following defines a function expression?
Explanation
A function expression defines a function and assigns it to a variable.
It can be named or anonymous and behaves like any other value in JavaScript.
Function expressions are not hoisted, so you must define them before using them.
They are widely used in callbacks, event listeners, and higher-order functions.
Use const to prevent accidental reassignment and keep code predictable.
Code Solution
SolutionRead Only
const sum = function(a, b) {
return a + b;
};
console.log(sum(5, 3)); // 8