The type of assignment I want to learn about probably has lots of explanations online, but I can't find them because I don't know what it's called. So what do you call this form of variable assignment in Javascript const {a, b, c} = x;?
It is called destructuring assignment.
It takes an object as value and variables, where the names reflects the same named properties and assigns the value to it.
const x = { a: 1, b: 2, c: 3, d: 4 };
const { a, b, c } = x;
console.log(a, b, c);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With