nerdexam
CIW

1D0-720 · Question #5

Which statement is true regarding methods in JavaScript?

The correct answer is A. Methods are functions stored as object properties. Option A is correct because in JavaScript, a method is simply a function that has been assigned as a property of an object - when you call obj.greet(), greet is a method because it's a function living inside obj. Why the distractors are wrong: B is the opposite of true - the…

Client-Side Scripting and Media Queries

Question

Which statement is true regarding methods in JavaScript?

Options

  • AMethods are functions stored as object properties.
  • BMethods cannot be called on objects.
  • CMethods are the same as JavaScript loops.
  • DMethods are used to link JavaScript to HTML.

How the community answered

(20 responses)
  • A
    90% (18)
  • B
    5% (1)
  • C
    5% (1)

Explanation

Option A is correct because in JavaScript, a method is simply a function that has been assigned as a property of an object - when you call obj.greet(), greet is a method because it's a function living inside obj.

Why the distractors are wrong:

  • B is the opposite of true - the entire point of methods is that they are called on objects (e.g., array.push(), string.toUpperCase()).
  • C confuses methods with loops (for, while), which are control-flow constructs, not object properties.
  • D describes <script> tags or event attributes - the mechanism for linking JS to HTML - which has nothing to do with methods.

Memory tip: Think of a method as an object's action - just as an object has properties (data it has), it has methods (things it does). If a function belongs to an object, it's a method.

Topics

#Methods#Functions#Object Properties#JavaScript Fundamentals

Community Discussion

No community discussion yet for this question.

Full 1D0-720 Practice