I have an Object a
like that:
const a = {
user: {
…
groups: […]
…
}
}
whereby there are a lot more properties in
You asked specifically for an ES6 way with Object.assign, but maybe someone else will prefer my more 'general' answer - you can do it easily with lodash, and personally I think that this solution is more readable.
import * as _ from 'lodash';
_.set(a, 'user.groups', newGroupsValue);
It mutates object.