I've tried to search over SE without great success, however link me to the right topic if I'm wrong.
What I'd like to achieve is use a shortcut of JS's ternary operator, let me explain myself :
In PHP, you can do something like
<?php
$var1 = "1"; //example
$var2 = ($var1) ?: "2";
echo $var2 //echoes "1";
?>
as you can see/may already know, ?:
returns $var1
when if evaluates to "true" (in this case !empty($var1)
, or "2" otherwise.
Now my question is, is there a way do achieve the same thing in Javascript?