CKTIS / JavaScript
Object property shorthand
Object property shorthand lets you write `{ name }` instead of `{ name: name }`: the identifier's name becomes the key, and its current value becomes the property's value. The exception is `__proto__`: `{ __proto__ }` creates an own data property from the binding's value, while `{ __proto__: __proto__ }` uses object-literal prototype-setter syntax and does not create that property.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
const object = { name }; // equivalent to { name: name }In an object literal, { name } creates a property with the string key "name", taking its value from the identifier name. It does not declare a variable; the reference must be readable.
The value is read when the object is created. Later assignment to the variable does not update the property. An object value remains shared rather than being deeply copied.
For a different key, use { label: name }; for a computed key, use { [key]: name }. The syntax const { name } = object is destructuring, not property creation. The syntax { name = 1 } is not a valid object literal.
Reference identifiers covered by this entry: object property shorthand.
Examples
let score = 7;
const player = { score };
score = 9;
console.log(player.score);
console.log(score);Result
7 9
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.