I just want to point out that this idiom is less clear and understandable.
"string" != typeof myVar && (myVar = "");
I read this and actually had to convert it to if / else in my head. Steve McConnell argued that there would be one line of code for the work, which I tend to agree with, and that this was due to an absurd violation. Also note that the built-in side effects are primarily risky, which is pretty egregious.
parameters = parameters || {};
var speed = parameters.speed || 60;
IMO is much more understandable, in part because it is such a well-established idiom. or
if(x && x.employer && x.employer.company === 'google')
is an explicit use of the idiom (you will get an exception if you do undefined.company, for example).
source
share