Language syntax

Array rest binding

Try the free JavaScript compiler

Collects remaining iterator values into a new array. Must appear at the end, with no trailing comma or default on the rest element. Nested objects remain shared.

Formal Syntax & Structure

javascript syntaxjavascript
const [head, ...tail] = iterable;

Working Example

Example Snippetjavascript
const [a,...b]=[1,2,3]; console.log(a,b.join("|"));
JavaScript Reference