I'm trying to desctructure an object into another object, I mean taking sub-set of properties from Object A to Object B. I'm doing it like this:
const User = new UserImpl();
User.email = user.email;
User.name = user.name;
User.family_name = user.familyName;
User.password = 'Test!';
User.verify_email = true;
User.email_verified = false;
User.blocked = false;
const {
email,
name,
family_name,
password,
verify_email,
email_verified,
blocked,
connection
} = User;
const res_user = {
email,
name,
family_name,
password,
verify_email,
email_verified,
blocked,
connection
};
return res_user;
but, is there a way to do it using Object.assign() ? or using arrow => function instead of having two variables or doing it in two steps?
Thanks