I’ve done a lot of code reviews, and a few issues in terms of readability definitely tend to repeat. Some of these tips are Javascript specific, however, some are universal. If you are an experienced developer, you might think these are obvious. In that case, feel free to share this article with a junior developer.

1. Returning true or false

There’s nothing wrong with returning true as a rule, however, when you’re doing something like this:

Many people like to bash javascript (js) with seemingly weird code examples that spew unexpected results. In some cases, those are the result of a truly weird js property or some legacy feature. However in most cases, js works just fine, as long as you read the fine print. Here’s one example I found on Twitter:

This is wild! Trying to run this example in the console gives us this:

Meyron Levanon

Fullstack software developer. I enjoy debates, fine foods, and good looking code. 😎

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store