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

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

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -