DEV Community

loading...

Discussion on: What do you think about the ternary operator?

Collapse
nektro profile image
Meghan (she/her)

Iirc if you surround the if/else statement in parentheses then it is valid in JavaScript as well and will assign the appropriate value to the variable

Collapse
z3ta profile image
Z3TA

Can you post an example ? I only get syntax error :/

Collapse
_andys8 profile image
Andy

Totally wrong. Statement vs expression. Assignment without mutation.