Destructure and rename a property in JavaScript

Let's assume that you have the following object:

let erik = {
    age: 30,
    city: 'Barcelona'

If you want to deconstruct and rename both properties:

let { age: years, city: town } = erik

console.log(years, town)
// 30 "Barcelona"

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.