JavaScript, maybe with the exception of PHP, is the worst widely used language. It is so hyperbolic awful that, akin to when one feels down and listens to sad songs to continue down, one feels the need to use it everywhere for everything. Its meme like terribleness spread to the server, spread to otherwise unthinkable uses of once a blinking pop up maker language; its corrosive effect has a permanent mark in the brain, up to when you find yourself accepting horrible malpractices as commom sense, no matter what they are.
Now, the programmer who is safe from the monstrosities of web development may be thinking it can’t be so bad. However, as I will show you, JavaScript tears down so many concepts taught in comp.sci. 101 that we can make long, nicely subdivided ordered lists about it (well, the list will probably come out with mixed formation and out of order numbering since it is JavaScript).
- Functions as only class citizens
Function as first class citizens are really nice, however JavaScript, as it does with everything, takes it a little to the extreme. The only thing which might be as versatile as a JavaScript function is Hokuto Shinken- but that can only be used by a single person at any given time whereas JavaScript is used by millions of unsuspicious programmers every day.
Who doesn’t find }}}} a form of modern art?
Then added somewhere in the middle to complete the seamlessness, functions also double as “classes”
and of course Function is a also a constructor
- Forget proper scoping
JavaScript has no concept of block scoping. Instead, functions (again) determine the scope of variables, which makes you write code as follows
just in case you feel like reusing a variable name. Misspelled a variable name? Don’t worry, the JavaScript engine will kindly infer you mean something declared elsewhere. Need to hide some implementation details? Have fun with
Ah, and don’t forget the this mess.
- Fake keywords
JavaScript has a wart unique to itself: a few widely used symbols that look like keywords at a initial glance are, in fact, names which can be redeclared- all of that without a preprocessor! One of them, the this construct has already been mentioned; undefined, on the other hand, is another example which opens the chance for very pleasant debugging. For instance, this is perfectly valid:
To top it off, even strings can be keywords sometimes.
- Duck typing
JavaScript brings to the table all the worst of dynamic typing. Like a duck who quacks like a duck, swims like a duck, walks like a duck but is in fact a platypus. There are no warnings or errors for assigning undeclared variables. Objects, even core ones, can be extended willy nilly. You can compare distinct types. God may have mercy on your soul if you try to reason about comparision behavior. Or typeof. Or casting.
What do you think it is gonna be commited at 3am when the coffee has run out?
To finalize this short carnival sideshow, a word of advice: do not let people fool you with talk of ES6, ES7 or ESn, strict mode or anyting of the sort- the only “viable” JavaScript is TypeScript Elm PureScript.