Implement full destructuring binding patterns with dedicated AST types
(BindingPattern, BindingElement, BindingTarget, Param) and cover grammar
for destructuring assignment (AssignmentPattern, AssignmentTarget).
Features: array/object patterns in let/const/var with defaults, holes,
rest elements, and nesting; function and arrow parameter destructuring;
destructuring assignment expressions ([a,b]=[b,a]); for-of/for-in with
destructured bindings; object shorthand properties ({x} means {x:x});
array elisions ([1,,3]). Includes 8 js262 fixtures and ~65 unit tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
14 lines
224 B
JavaScript
14 lines
224 B
JavaScript
var obj = {x: 10, y: 20, z: 30};
|
|
let {x, y, z} = obj;
|
|
console.log(x);
|
|
console.log(y);
|
|
console.log(z);
|
|
|
|
let {x: a, y: b} = {x: 1, y: 2};
|
|
console.log(a);
|
|
console.log(b);
|
|
|
|
let {p, q} = {p: 100};
|
|
console.log(p);
|
|
console.log(q);
|