Blog.

How to rename a destructed variable

Cover image for How to rename a destructed variable

How to rename a destructed variable

This example is shameless stolen from Wes Bos. Seriously, go check it out, and buy a tutorial from him. They're awesome.

The object we will destruct.

const person = {
  name: "John Snow",
  knows: null,
  alive: undefined,
  social: { facebook: "johnoftheblack", twitter: "thekinginthenorth" },
}

Now to destructure it.

const { facebook: fb, twitter: tweet } = person.social