What is destructuring in JavaScript?

You may have come across a term on your JavaScript adventures - destructuring assignment. Sounds scary, but it's actually incredibly useful.

Destructuring in JavaScript is basically getting something out of an array or object and assigning it to a variable. Here's an example:

const person = {
    firstName: 'Jimmy',
    lastName: 'McCoder',
    age: 28
}

const { age } = person

//will log '28'
console.log(age)

This is part of the JavaScript bite-size series of posts. Check out the rest here!