If you don’t know what destructuring in javascript is, check out The power of Javascript ES6 – Destructuring and Rest/Spread Operator. This feature is great to write more concise code.

Here is a simple destructuring example:

const person = { name: 'Andy' };
const { name } = person;

The code above works the same as if you would do:

const person = { name: 'Andy' };

When destructuring, you might want to rename the destructured variable. For that you will have to use the following syntax: : newName.


const person = { name: 'Andy' };
const { name: myName } = person;

While this alias syntax is useful, I try to avoid it when possible because it makes the code more confusing.