const rec = {w: 10, h: 2}; console.log(rec); const {w} = rec; console.log('Width: ' + w); let h; /* This does not work: h = rec; */ //Outer parens allows this to work ({h} = rec); console.log('Height: ' + h);
const array = [10, 20, 30, 40]; let a, b, remaining; [a, b, ...remaining] = array; console.log('a: ' + a); console.log('b: ' + b); console.log('remaining: ' + remaining);