This question already has an answer here:
Let's say I have obj like
const user = {
id: 339,
name: 'Fred',
age: 42,
education: {
getDegree: () => {} //function
}
};
const {education: {getDegree}} = user;
I often have a use case that needs to get both education and degree as parameter from user obj.
I only know how to destruct getDegree from obj, what to do to get the education variable as well?
something to do the same thing, but I believe there is a better way to do this?
const {education: {getDegree}} = user;
const {education} = user;