Explanation:
A function literal (also called a function expression) is a way of defining a function directly within an expression. It's called a "literal" because you're creating a function object literally in your code. This is often used when passing a function as an argument or when assigning it to a variable.
For example:
const add = function(a, b) {
return a + b;
};
Here, function(a, b) { return a + b; } is a function literal. It's an anonymous function (not named) created directly as an expression and assigned to the variable add.
Why the other options are incorrect:
(A) Function calling: Refers to invoking or executing a function, not defining it.
(B) Function prototype: Refers to the definition of a function's interface (i.e., the function signature), typically seen in constructor functions or classes.
(C) Function declaration: Refers to a function defined using the function keyword with a name, like this:
This is different from a function expression (or literal), as the function is not immediately part of an expression but rather declared in a statement.
So, the correct term for a function definition in an expression form is (D) Function literal.
function add(a, b) {
return a + b;
}