Sitemap
Before Semicolon

Learn about programming from professionals

Member-only story

50 JavaScript Best Practice Rules to Write Better Code

Elson TC
10 min readNov 5, 2020

--

JavaScript is powerful and flexible which allows you to code any way you like and try some very unusual things which can lead to a bug in your code. Here are 50 things I learned about coding in JavaScript you should know about.

Always “use strict” On

Chances are that if you are using any library/framework or compiler for your JavaScript, “use strict” is on but just in case you are not, remember to add it to the file and to the functions. It will make sure you get errors that would happen silently if you don't include it.

Use Function expressions instead of Function Declarations

Unless you want to take advantage of Function behavior and properties, prefer function expressions. Function declarations are hoisted and although it can be useful sometimes, avoid them as they introduce weird behavior to the code and it is not always obvious what's happening. Try to make it clear where the function you are using comes from and they come before you use them to avoid weird access.

--

--

Before Semicolon
Before Semicolon
Elson TC
Elson TC

Written by Elson TC

Software Engineer sharing knowledge, experience, and perspective from an employee and personal point of view.

Responses (12)