Why I hate JavaScript 🤷

Kaamkiya - Dec 3 '23 - - Dev Community

I understand that a lot of you will disagree with me. This is extremely opinionated, and you don't have to agree.

JavaScript was made in ten days (originally), but it still shows.

Reasons

No strict typing

I do not like the fact that JavaScript has no strict typing. I know that some people like that all of their variables are dynamic, but not me. I also do know about TypeScript, but I think that it is redundant (that is a topic for another article).

Only web language

It is, unfortunately, the only web language. So we have to use it all the time. I understand WebAssembly exists, but it is harder than JavaScript, and it must still be called by a JavaScript script.

The equality operator (==)

How is NaN not equal to NaN? Try running the following JavaScript anywhere:

if (NaN == NaN) {
  console.log('This makes sense.');
} else {
  console.log('This is really silly.');
}
Enter fullscreen mode Exit fullscreen mode

It will output This is really silly. Somehow, [] == 0 is true, and NaN == NaN is false.

There are so many other things wrong with the equality operator.

There is a === operator, which does not try to convert types, but it requires an extra equals. In my opinion, the == should not convert types, and we shouldn't even need the ===.

Weird behaviour

[] + [] // => "" - Somehow gives an empty string
[] + {} // => [object Object] - ok, this makes sense...
{} + [] // => 0 - why does this not give the same as above?!
{} + {} // => NaN - why? They're objects, and it's addition!
Enter fullscreen mode Exit fullscreen mode

Too many frameworks and libraries!

I should not, when starting a new project, have to choose between frameworks. That is insane. If I am, say, making the frontend for a bank, I should not be asking myself, "Should I use Angular? Or React? Probably React. No, wait, Vite! Or Svelte!" No other language has this problem.

The var keyword

It's highly recommended that you don't use it. So the why does it exist?! All of the ways to declare a variable

let a = 5; // good
const b = 6; // good
var c = 7; // bad
d = 8; // awful
Enter fullscreen mode Exit fullscreen mode

Why does assignment have so many options when only 2 are good? I do not know, and I hate it.

Other stuff

  • The this keyword is a nightmare
  • NodeJS: taking user input is like rocket science
  • NPM is terrible
  • this keyword is honestly messed up
  • And so much more...
. . . . . . . . . . . .