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>
10 lines
197 B
JavaScript
10 lines
197 B
JavaScript
var pairs = [[1, 2], [3, 4], [5, 6]];
|
|
for (const [a, b] of pairs) {
|
|
console.log(a + b);
|
|
}
|
|
|
|
var items = [{x: 10, y: 20}, {x: 30, y: 40}];
|
|
for (const {x, y} of items) {
|
|
console.log(x + y);
|
|
}
|