What are some the most stressful parts of JavaScript in your opinion especially coming from a different programming language ?
I get to hear these ones from people but some of the most popular ones have been:
- Asynchronous programming
- Anonymous functions
- Implicit Coercion
-
this
keyword
Would like to hear from other you folks!
Top comments (2)
this
is probably the biggest one for me too. The binding rules are not immediately obvious, and it's compounded by how it behaves differently in arrow functions.I don't quite get people complaining about anonymous functions as if they're JS specific though, most HLL's have them these days, they just don't force you to use them to quite the same degree that JS does (see for example lambda expressions in Python, I know quite a few Python developers who don't even know they exist because they're that rarely used).
The other really big one for me though is the whole ES6 module system. Short list of issues I have with it:
import foo
behaves differently from almost every other widely used programming language. In most languages, that (orrequire foo
, orusing foo
, or whatever else the language does instead ofimport
) loads the modulefoo
and binds it's contents to the namefoo
in the local scope. In JS, it loads the modulefoo
, runs the top-level code, and then moves on to the next statement without doing anything else with the contents of the modulefoo
. Were it not for the next point, I could probably tolerate this because it means you can have plain (non-modular) JS as a dependency of a module.import foo as bar
behaves differently from many other widely used programming languages. In most languages, that (or it's direct equivalent) is the same asimport foo
, just with a rebinding to a different name in the local scope. In JS, it loads the modulefoo
and looks for an export calleddefault
and then binds that to the local namebar
. This one wouldn't be an issue if it weren't for the next point.Now, I'm not hugely fond of AMD or CJS either for their own reasons, but at least they're more sensible than what was decided on for ES6.
I live in fear of being asked to explain JavaScript's prototype inheritance in detail and how it differs from the standard class inheritance you see in other languages. Luckily it hasn't really ever been an issue for me on a practical level but I definitely think it's a confusing concept to fully grok and be able to explain to other people intelligently.