Index
Examples


The object destructuring assignment (of an object) is highlighted (two different approaches).
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);
The object destructuring assignment (of an array) is highlighted.
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);




References