Javascript shorthand an if statement -
this question has answer here:
- shorthand if/else statement javascript 5 answers
what shorthand equivalent of following?
if (windowwidth >= 960){ widthofwindow = 1; } else { widthofwindow = 0; }
you use ternary operator:
widthofwindow = windowwidth >= 960 ? 1 : 0
you read as
condition ? value_if_true : value_if_false
Comments
Post a Comment