I am using ES6 Object destructuring syntax . I want to use it to populate an existing object.
I have two objects:
let $scope = {};
let email = { from: 'cyril@so.com', to: 'you@so.com', ... };
I want to assign some properties of an object to an email
object $scope
.
I am currently doing this:
({ from: $scope.from, to: $scope.to } = email);
In my use case in real life, I have more than two properties that need to be assigned.
So, do you know another way to improve and avoid repetition $scope
on the left side of the destination?
source
share