Snippets on Javascript ES6
Destruction
case: convert object
const points = [
[4, 5],
[10, 1],
[0, 40]
];
to
[
{ x: 4, y: 5},
{ x: 10, y: 1},
{ x: 0, y: 40}
]
// ES5:
points.map( pair => {
const x = pair[0];
const y = pair[1];
});
// ES...
archerzou.hashnode.dev3 min read