To make code easy to read and maintain, we should follow some best practices.
In this article, we’ll look at some best practices we should follow to make everyone’s lives easier.
Dangling underscores are used for identifying private variables whether they’re actually private or not.
It’s best not to use this since if they’re not private, people may think it’s private.
So instead of writing:
foo._bar();
We write:
foo.bar();
We should separate statements and expressions with semicolons when they need to be separated.
For instance, we shouldn’t code like:
const foo = bar
[1, 2, 3].forEach(log);
We don’t know if the 2 lines should be together or not.
Instead, we write:
const foo = bar;
[1, 2, 3].forEach(log);
to separate them clearly.
#javascript #software-development #technology #web-development #programming