As an inaugural post to The Dropout Dev, why not rant about how bad JavaScript is, I mean, what good is a tech/programming blog without a post about JavaScript? And everyone needs to start somewhere right...

Let me start by saying I don't hate JavaScript. I think it for sure has valid uses and I think there are some great libraries and tools written using JavaScript, and it has definitely changed the way the world views the web. In fact, this blog would not exist without JavaScript.

The main issue with JavaScript is that it encourages bad habits.


I'm not one to preach that strict typing is necessary, I personally prefer it as it tends to make debugging and even just programming easier, but the way JavaScript implements type coercion is terrible. I think generally it should not be that:

1 == "1" 
1 == true
"1" == true
0 == "0"
0 == []
0 == false
0 == " "
0 == ""
0 == "\n"
[] == false
[] == ""
[] == ![]
false == ""
false == " "
false == "\n"
null == undefined

Note that all of the above will return true in JavaScript. That's just the tip of the insanity iceberg though. For instance, you might think that this shows that everything is either "truthy" or "falsey". Well that's not true either since neither null nor undefined are true or false. Want to go deeper down the rabbit hole? Check out JSF*ck.


JavaScript's scope is solely on a function level, while most languages use block level scoping. This isn't necessarily bad, but it definitely does lead to bad design and bad code. For instance it lets you do something like:

    for(var i = 0; i < 5; i++){
        //do some things

what's even worse, is if you assign a variable without using a var/ let/ const keyword, it creates a global variable. So you can do something like this:

function() {
    x = 15 //x is now global

and this can and will cause bugs that can be hard to track down (ever forget a semicolon?)

Another fun scoping "feature" is when you do something like this:

    var x = 10
    //do things
    if(x == 4)
        var y = 12
    return y //y is visible outside the if block

This can and will definitely lead to problems and bugs, especially if you are not used to JavaScript's "quirks"


JavaScript for some reason decided to have two types of string, a string and a String. doing something like var x = "string" will yield a string. But if you were to do, var x = new String("string") you end up with a String. Why? ¯\_(ツ)_/¯  I dunno.


There's more, there's a lot more and I could go on and on, but these are the main problems I think. JavaScript was created in 1995 in 10 days, and instead of fixing a lot of the mistakes/oversights, they seem to have been even more baked in. Is it possible to write good JavaScript code? Yes of course it is. But it is definitely outside the norm, as it seems to pull you down the wrong path whenever it can.