JavaScript ternary if statement

conditional-operatorif statementjavascriptshortcut

I would like to know what's the shortcode of if in javascript?

Like in php:

$res = ($x > $y)? $x: $y;

What's its conversion in javascript?

Best Answer

It's the same in javascript :)

var res = (x > y) ? x : y;