tc39/proposal-object-rest-spread

Rest/Spread Properties for ECMAScript

HTML

1,487

107 commits

updated Jan 24, 2022

See the code

README

Object Rest/Spread Properties for ECMAScript

ECMAScript 6 introduces rest elements for array destructuring assignment and spread elements for array literals.

This proposal introduces analogous rest properties for object destructuring assignment and spread properties for object literals.

Specification

Specification

Rest Properties

Rest properties collect the remaining own enumerable property keys that are not already picked off by the destructuring pattern. Those keys and their values are copied onto a new object.

let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
x; // 1
y; // 2
z; // { a: 3, b: 4 }

Spread Properties

Spread properties in object initializers copies own enumerable properties from a provided object onto the newly created object.

let n = { x, y, ...z };
n; // { x: 1, y: 2, a: 3, b: 4 }

Transpilers

Babel

Bublé

JSTransform

TypeScript

Status of this Proposal

It is a Stage 4 proposal for ECMAScript.

Known Issues

This proposal only iterates over own properties. See why this matters.

tc39/proposal-object-rest-spread

Rest/Spread Properties for ECMAScript

HTML

1,487

107 commits

updated Jan 24, 2022

See the code

README

Object Rest/Spread Properties for ECMAScript

ECMAScript 6 introduces rest elements for array destructuring assignment and spread elements for array literals.

This proposal introduces analogous rest properties for object destructuring assignment and spread properties for object literals.

Specification

Specification

Rest Properties

Rest properties collect the remaining own enumerable property keys that are not already picked off by the destructuring pattern. Those keys and their values are copied onto a new object.

let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
x; // 1
y; // 2
z; // { a: 3, b: 4 }

Spread Properties

Spread properties in object initializers copies own enumerable properties from a provided object onto the newly created object.

let n = { x, y, ...z };
n; // { x: 1, y: 2, a: 3, b: 4 }

Transpilers

Babel

Bublé

JSTransform

TypeScript

Status of this Proposal

It is a Stage 4 proposal for ECMAScript.

Known Issues

This proposal only iterates over own properties. See why this matters.

Project health

Overall

3.4/10

Maintained

0/10

Code review

6/10
OpenSSF Scorecard

Significant stargazers

Simen Bekkhus

1,283 followers · starred Apr 2017

wolfy1339

130 followers · starred Feb 2018

Mike

1,803 followers · starred Jun 2015

Alexander Kachkaev

268 followers · starred Apr 2017