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

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -