I agree with one of the other commenters, this is more about more concise code than it is clean code.
Some of these would not fly if I was doing the code review.
Particularly 6 (this is replacing 4 simple assignments by creating a number of intermediate objects, and the code takes more time to grok what's going on).
4 replaces the two assignments with more code, not less, and arguably little performance improvement.
2 is:
a = { [c > d ? 'foo' : 'bar']: 'apple' };
I'd put that into two lines:
const prop = c > d ? 'foo' : 'bar';
a[prop] = 'apple';
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I agree with one of the other commenters, this is more about more concise code than it is clean code.
Some of these would not fly if I was doing the code review.
Particularly 6 (this is replacing 4 simple assignments by creating a number of intermediate objects, and the code takes more time to grok what's going on).
4 replaces the two assignments with more code, not less, and arguably little performance improvement.
2 is:
a = { [c > d ? 'foo' : 'bar']: 'apple' };
I'd put that into two lines:
const prop = c > d ? 'foo' : 'bar';
a[prop] = 'apple';