DEV Community

Discussion on: short-circuits && clean code

Collapse
 
lexlohr profile image
Alex Lohr

In my opinion, the only few places where those are justified are variable declarations, e.g.

const myFunc = function (options) {
    options = options || {};
    const debugLevel = /debuglevel=(\d+)/.test(location.href) && RegExp.$1;
    // ...
}

Otherwise rather write the long variant in development code and use a minifier for production code, you'll end up using the shorter version while still having the longer one for ease of maintenance.