Object Methods Quiz
Multiple Choice Easy
Question
Which is valid ES6 method shorthand for an object property?
Hint
ES6 allows omitting 'function' and the colon for methods.
Explanation
ES6 method shorthand lets you write greet() { return 'hi'; } inside an object literal, which is equivalent to greet: function() { return 'hi'; }. The other options have invalid syntax. This shorthand is commonly used in class definitions and object literals.
Related Resources
Related Lessons
- JavaScript Objects
Learn about object methods.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.