Language syntax

Object destructuring

Try the free JavaScript compiler

Reads properties by key, including inherited properties. The colon chooses a local binding name. A nullish source throws TypeError; an undefined property triggers the default.

Formal Syntax & Structure

javascript syntaxjavascript
const { key: local = fallback } = source;

Working Example

Example Snippetjavascript
const {price:p=9}={price:4}; console.log(p);
JavaScript Reference