Expressions

Bracket property access

Try the free JavaScript compiler

Evaluates the key expression and converts it to a property key. Useful for variable names, symbols and keys with spaces. Nullish base values throw TypeError.

Formal Syntax & Structure

javascript syntaxjavascript
object[key]

Working Example

Example Snippetjavascript
const a={price:3}; const k="price";console.log(a[k]);
JavaScript Reference