Object Property Shorthand
Multiple Choice Easy
Question
What does { x, y } mean when x=1, y=2?
Hint
Shorthand uses variable names as property names.
Explanation
{ x, y } is ES6 shorthand for { x: x, y: y }. When x is 1 and y is 2, it creates { x: 1, y: 2 }. The property name is taken from the variable name. This is commonly used when returning objects from functions: function f() { let x = 1; let y = 2; return { x, y }; }
Related Resources
Related Lessons
- Objects
Learn JS objects.
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.