Expressions

Computed property name

Try the free JavaScript compiler

Evaluates an expression and uses the resulting property key to define a property in an object literal or other supported definition. Distinct from later bracket access.

Formal Syntax & Structure

javascript syntaxjavascript
{ [expression]: value }

Working Example

Example Snippetjavascript
const key="count"; const a={[key]:7};console.log(a.count);
JavaScript Reference