Language concepts

Property keys

Try the free JavaScript compiler

Ordinary property keys are strings or symbols. Numeric keys are converted to strings in ordinary property access; a symbol key retains identity. Dot notation specifies a name directly; bracket notation evaluates an expression and converts it to a property key.

Formal Syntax & Structure

javascript syntaxjavascript
record[key]

Working Example

Example Snippetjavascript
const key = Symbol("item");const record = { item: 3 };record[key] = 4;console.log(record.item + record[key]);
JavaScript Reference