Destructuring Assignment in Javascript
Javascript offers desctructuring assignment for array values and object properties. The syntax works like this:
// First we need an object to refer to
const pizza = {
crust: "thin",
topping: "pepperoni",
deliveryDriver: "Jack"
}
//Then we can use a destructuring assignment
const {crust} = pizza
console.log(crust)
// expected output: thin
Very handy
Tweet