Skip to content
Advertisement

Tag: conditional-operator

Variable reassignment with chained booleans or ternary operator [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question To clarify: This is purely for experimental purposes, to learn the quirks, odds

checking for null in javascript

I have the above if-else-if chain in the code, trying to see if I can write the same logic in one or two lines. Answer Since you want to distinguish between three types of values, you have to make at least two checks already. The else case will never be hit since either !valid or valid will be true. That

Alternative to nested ternary operator in JS [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 months ago. Improve this question I personally love ternary operators, and in my humble opinion, they make complicated expressions very easy to digest. Take this one:

Advertisement