Lets say I have an object
obj = {
name: 'Karthi',
age: 25,
gender: 'Male'
}
and I want to assign some of the values to a key with the same name in another object.
objTar = {
name: obj.name,
age: obj.age
}
Is there a shorthand for the above "nested" assignment? I know there's a shorthand for flat assignments; eg., objTar = { name, age }
given name
and age
are available in the lexical scope.
Don't suggest workarounds to achieve this please. Just let me know if this is "natively" supported.