1.
Which of the following is the correct way to invoke a function in JavaScript?
execute myFunction();
call myFunction;
myFunction;
myFunction();
Correct: D
The correct way to invoke a function in JavaScript is by using parentheses after the function name. This executes the code inside the function and returns any result or performs any intended actions. Option myFunction simply refers to the function itself without invoking it, while the other two options use incorrect syntax.
function add(a, b) {
return a + b;
}
// Invoke the function
const result = add(1, 2);
console.log(result); // Output: 3
1 / 34