Unnecessary elses
I often see code like that:
function foo() {
if (condition) {
return something;
} else {
doSomethingElse();
}
}
Because the first condition returns and is followed with an else, this can be simplified into:
function foo() {
if (condition) {
return something;
}
doSomethingElse();
}
Which remove an indentation level and simplifies the code readability, in my opinion.
Written by padawin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Readability
Authors

anoras
12.16K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#