5 ms·
90% of the time I prefer the first. I am allergic to indentation and I hate anything remotely like: function foo(a) { if (a) { return d
by zoogeny 2y ago
90% of the time I prefer the first. I am allergic to indentation and I hate anything remotely like:
function foo(a) {
if (a) {
return doThing()
} else {
return Error();
}
}
I like all of my assertion and predicate guards nicely at the top of a function:
function foo(a) {
if (!a) {
return Error()
}
return doThing()
}
And for that reason, I would probably go for getOddness4 even though I see your point.
- stared 2y agoIn case of handling exceptions (and similar stuff), I also prefer avoiding unnecessary nesting. For two (or more) equally valid, I prefer keeping same nesting.