Good question and several useful answers so far! Here are some of the bad practices I have encountered:
if (x) {
return 1;
}
else {
// Do something else
}
var isPublication = "publicationId";
return (x === 1 ? true : false);
dosomething(10, 12, (data) => {
doSomethingElse(data, (something) => {
doAnotherThing(something, () => {
// More callbacks
});
});
});
Making typos and copying the typos everywhere because you couldn't notice. Sometimes you misspell a variable name and copy-paste it to different places -- it works -- However, when other collaborators glance over the variable name and try to use it in some section, the code simply doesn't work. It wastes a lot of time because we are not able to figure out that the original variable name is incorrect.
Failing to return early by mistake. Some developers accidentally skip return keyword while returning early in case of error.
if (err) {
res.status(400).end(); // This doesn't halt the execution of code
}
// rest of the code
There are many more, but these are the ones I've come across most frequently. I have always highlighted them in the code reviews so far. :D
If you're retrieving from a database, you might leave the connection open.