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
Here is a way to do it that works, but may not be best practise for any language really:
var x,y; x='something'; y=1; undefined === y || (x = y);
alternatively
undefined !== y && (x = y);