how can one achieve ternary assignment in javascript?

Great question. Unfortunately this is not possible. There is a shorthand version that some people use, but it still includes a duplication:

foo = foo || otherCondition;

So the shorthand of a shorthand, not too useful in my opinion.

Short answer: I’d go with the normal ternary.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top