★ wanayoo — archive 1999 https://github.com/sebmarkbage/ecmascript-rest-spreadNouvelle recherche | Portail wanayoo
Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rest/Spread Properties for ECMAScript
branch: master

README.md

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.

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 }

Status of this Proposal

A polyfill of this proposal was implemented in JSTransform which can compile rest and spread properties syntax to ES6 code. It is a Stage 1 proposal for ECMAScript 7.

Known Issues

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

Something went wrong with that request. Please try again.