November 2019
Beginner
804 pages
20h 1m
English
In this section, we'll explain object destructuring, a JavaScript syntax that can be used to easily extract parts of other objects. Knowing about this feature will prove useful for writing React components, but you can also leverage it in many more situations.
Destructuring is often useful when you are only interested in a subset of the properties of an object returned by a function call.
Here's a simple example:
const myObject = {
firstName: 'Sebastien',
age: 36,
country: 'Belgium',
};
const {firstName, age} = myObject;
console.log(`Firstname: ${firstName}`);
Here, we first defined an object with multiple properties. Then, using ...
Read now
Unlock full access