I\'m wondering if there\'s a shorter way to write this:
var x = 1; if(y != undefined) x = y;
I initially tried x = y || 1, but
x = y || 1
Other way is using short-circuit:
x = (typeof y !== 'undefined') && y || 1
Although I myself think that ternary is more readable.