I think you should also cover "The optional chaining operator (?.)" as spread operator is used to accessing deeper values in objects with safe defaults.
Could you provide an example of how it's related to the spread operator?. Or is it used along with spread operator? I'm not quiet sure how to relate that with the spread operator.
I think you should also cover "The optional chaining operator (?.)" as spread operator is used to accessing deeper values in objects with safe defaults.
Could you provide an example of how it's related to the spread operator?. Or is it used along with spread operator? I'm not quiet sure how to relate that with the spread operator.
Example with optional chaining operator
let customer = {
name: "Carl",
details: {
age: 82,
location: "Paradise Falls" // detailed address is unknown
}
};
let customerCity = customer.details?.address?.city;
With spread operator
let { details: { address: {city: customerCity } ={}} = {} } = customer || {}