09 Common Mistakes Developers Make in JavaScript

How to Correct These Common JavaScript Mistakes?

Fakhreddine Messaoudi
Nerd For Tech

--

JavaScript is a scripting language used to add functionality and interactivity to web pages. For a beginner coming from a different programming language, JavaScript is quite easy to understand.

With a few tutorials, you should be able to get started with it right away. However, there are some common mistakes that many beginner programmers make. In this article, we’ll address nine common mistakes (or bad practices) and their solutions to help you become a better JS developer.

Confusing the assignment (=) and equality (==, ===) operators

As its name implies, the assignment operator(=) is used to assign values ​​to variables. Developers often confuse it with the equality operator.

Here is an example:

const name = "javascript";
if ((name = "nodejs")) {
console.log(name);
}
// output - nodejs

In this case, the name variable and the ‘nodejs’ string are not compared. Instead, ‘nodejs’ is named, and ‘nodejs’ is printed to the console. In JavaScript, the double equal sign (==) and triple equal sign (===) are called comparison operators. For the code above, the appropriate way to compare values…

--

--

Fakhreddine Messaoudi
Nerd For Tech

Was man shreibt, bleibt. Support my writing with a simple follow and clapp!