How do you write a function expression in JavaScript?
a) let myFunction = function() { … }
b) function = myFunction() { … }
c) def myFunction() { … }
d) fn myFunction() { … }
Answer:
a) let myFunction = function() { … }
Explanation:
In JavaScript, a function expression is a function assigned to a variable. The function can be called using the variable name.
Example:
let greet = function() {
console.log("Hello, World!");
};
greet(); // Output: "Hello, World!"