if statement - Javascript expression shortage: value? value:'100' -
is there shorter way write expression
value? value:'100' the way don't type value twice?
something (but wrong)
value? : '100' //take value unless empty/null/false/undefined/0, otherwise accept '100'.
or, whatever possible fine.
you can use logical or operator:
value || '100' it'll return value if it's truthy (!!value === true), else '100'.
Comments
Post a Comment