← #74 Toggle hidden files on macOS

Unpack a property of an object with different name

Topics: JavaScript

We can use the destructuring assignment syntax to unpack a property of a given object and rename it:

const person = {
name: 'John Doe',

const { name } = person;

// Or unpack with other name
const { name: fullName } = person;

In the sample code above, fullName is an alias of the name property. Both the name and fullName variables are John Doe.

Fix a typo or suggest an improvement
#76 Run the last command as the root user