Skip to content

Latest commit

 

History

History
10 lines (9 loc) · 280 Bytes

destructuring.md

File metadata and controls

10 lines (9 loc) · 280 Bytes

Destructuring allows for more flexible and compact assignments

let x = 'why', y = 'ex';
[y, x] = [x, y];
// x = 'ex', y = 'why'

const pages = [{title: 'Home'}, {title: 'Footer'}];
const [{title}, {title: secondTitle}] = pages;
// title = 'Home', secondTitle = 'Footer'