Javascript shorthand an if statement -


this question has answer here:

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

Popular posts from this blog

matlab - Deleting rows with specific rules -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -