nerdexam
CIW

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…

Client-Side Scripting and Media Queries

Question

How do you call a function named myFunction in JavaScript?

Options

  • Acall myFunction();
  • BmyFunction[];
  • CmyFunction();
  • Dfunction myFunction();

How the community answered

(29 responses)
  • A
    3% (1)
  • C
    93% (27)
  • D
    3% (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()) - call is 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

#Function invocation#JavaScript syntax#Function calls#Basic JavaScript

Community Discussion

No community discussion yet for this question.

Full 1D0-720 Practice