1D0-720 · Question #21
How do you call a function named myFunction in JavaScript?
The correct answer is C. myFunction(). In JavaScript, functions are invoked by writing the function name followed by parentheses, making myFunction() the correct syntax. The parentheses are what actually trigger the function call - they can also hold arguments if needed. Why the distractors are wrong: A (call…
Question
How do you call a function named myFunction in JavaScript?
Options
- Acall myFunction();
- BmyFunction[];
- CmyFunction();
- Dfunction myFunction();
How the community answered
(29 responses)- A3% (1)
- C93% (27)
- D3% (1)
Explanation
In JavaScript, functions are invoked by writing the function name followed by parentheses, making myFunction() the correct syntax. The parentheses are what actually trigger the function call - they can also hold arguments if needed.
Why the distractors are wrong:
- A (
call myFunction()) -callis not a keyword for invoking functions in JavaScript; it reads like pseudocode or another language's syntax. - B (
myFunction[]) - square brackets are used for array indexing or object property access, not function calls. - D (
function myFunction()) - this is the syntax for declaring/defining a function, not calling one that already exists.
Memory tip: Think of parentheses as a "trigger" - no (), no execution. If you see [], think arrays; if you see function keyword, think definition, not invocation.
Topics
Community Discussion
No community discussion yet for this question.