Language syntax

Object literal spread

Try the free JavaScript compiler

Copies enumerable own string and symbol properties as data properties. Reads getter values, ignores nullish sources, and allows later definitions to overwrite keys. Does not clone nested objects or prototype descriptors.

Formal Syntax & Structure

javascript syntaxjavascript
({...source, key: value})

Working Example

Example Snippetjavascript
const base={x:1}; const b={...base,x:2}; console.log(base.x,b.x);
JavaScript Reference