5 Reasons why javascript is hated by developers.

ankysony

Ankit Soni

Posted on August 3, 2020

5 Reasons why javascript is hated by developers.

Javascript is a programming language build by Brendon Eich in April 1995. He was told to make a language to run in Netscape's browser and that too within 10 days.
The hard part was producing a rich and powerful language while being prohibited from using the object-oriented syntax reserved for Java. A lot of developers hate this language. Below is a comparison of it from other languages.

Comparision of programming languages

In this graph, you can easily see how fast javascript has grown in terms of job opportunities from 2019 - 2020. Now you may have a doubt why it is so popular even if there are so many people who hate this language. In this post, I have tried to give you some reasons why it is being hated.

Reason 1. Loosely typed language.

Javascript is a loosely typed language, but what does it mean? It means that you don't have to declare the type of a variable while defining it.

  • Case 1: Variables without defining any data types.
let a = 2; console.log(typeof a); // logs out number a="coding"; console.log(typeof a); // logs out string
  • Case 2: NaN is a number (quite confusing)
console.log(typeof NaN) // logs out number;
  • Case 3: You can mix different data types in an array.
array = ["banana", 2 , {name: "ankit" , lastname: "soni" } ]; // please click on the run button below to see the log. console.log(array[0] +" "+ typeof array[0]); console.log(array[1] +" "+ typeof array[1]); console.log(array[2].name+" "+array[2].lastname+" "+ typeof array[2]);

Reason 2. Concept of "==" && "===".

In very simple words "==" cares about equality of two variables without caring about the data types, whereas "===" cares about the equality as well as the data type of both the variables. Let's understand it better by the following example.

var a = 1; var b = "1"; console.log(a == b); // prints true console.log(a === b); // prints false

In third line of code, double equals does not care about the data types of the variables which are different and then prints true, whereas triple equals strictly care about the data types of the variables and hence prints false.

Reason 3. Functions can call themselves (IIFEs)

IIFE stands for immediate invoked function experssion. Lets learn its logic.

(function(name) { console.log(name); //logs out "Welcome to the ankit's blog". })("Welcome to the ankit's blog");

This function calls itself by adding parentheses at the end of the function definition.

Reason 4. Adding two variables of different data type

Look at the following example and try to think about the output.

var a = "12"; var b = 3; console.log(a + b); // logs out 123 console.log(+a + b); // logs out 15

It logs out "123" and 15 in the console but how is it happening. Javascript says that when you add number and string then number changes to a string, whereas when you put a plus sign before a string then string changes to a number which is quite bizarre.

Reason 5. Javascript performs differently for different browsers.

This generally happens due to the reason that every browser has its different ECMAScript engine which it uses to compile javascript code. Most famous ones are V8 by google chrome and spiderMonkey by mozilla firefox. Javascript is different from languages like c, c++ and java. Java codes are compiled the same on all the devices which are using JVM in their machines, but that does not happen with javascript. Hence a developer has to look at how their website is performing in different browsers.

Conclusion

I showed you a lot of negatives about this language but don't dare to judge this language to be crappy. It has a huge internet community, as well as a lot of frameworks and libraries, are running on it. Below is the list of some of them.

If you are still reading it. Consider reading my blog on promises by clicking on the following link.

Thank you!
💖 💪 🙅 🚩
ankysony
Ankit Soni

Posted on August 3, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related