1D0-720 · Question #86
What is the role of methods in JavaScript objects?
The correct answer is B. To perform actions or operations. Methods in JavaScript objects are functions attached to an object that perform actions or operations - for example, car.start() or user.login() - making B correct. They define behavior, not storage. A is wrong because storing data is the role of properties (e.g., obj.name =…
Question
What is the role of methods in JavaScript objects?
Options
- ATo store data
- BTo perform actions or operations
- CTo link to other web pages
- DTo structure the HTML document
How the community answered
(29 responses)- A3% (1)
- B93% (27)
- D3% (1)
Explanation
Methods in JavaScript objects are functions attached to an object that perform actions or operations - for example, car.start() or user.login() - making B correct. They define behavior, not storage.
- A is wrong because storing data is the role of properties (e.g.,
obj.name = "Alice"), not methods. - C is wrong because linking to web pages is the job of HTML anchor tags (
<a href="...">), unrelated to JS object methods. - D is wrong because structuring HTML documents is what HTML elements and the DOM do, not JavaScript object methods.
Memory tip: Think of an object as a person - properties are who they are (name, age), and methods are what they do (walk, talk). "Methods = actions" maps directly to the object-oriented concept of behavior.
Topics
Community Discussion
No community discussion yet for this question.