r/javascript • u/Scared-Release1068 • Mar 12 '26
AskJS [AskJS] What concept in JS is the hardest to learn and understand?
Was talking to friends about how I didn’t completely get asynchronous code at first and they said it was odd that I understood DOMs and how stack data structures work but asynchronous Code was confusing me.
Got me wondering what do you guys find to be hard or difficult in JS?
10
Upvotes
22
u/Glasgesicht Mar 12 '26
Prototype chaining is fairly unique to JS and not widely used, so it's a somewhat misunderstood concept.
10
u/pie6k Mar 12 '26
Nuances of closures of variables and lifetime of variables attached to certain function closures
7
u/smartgenius1 Mar 12 '26
Memory leaks. It's very difficult to ensure you properly clean up everything, especially when attaching events or manipulating DOM. WeakMap helps but it's no silver bullet.
6
u/prehensilemullet Mar 12 '26
DOMs and stacks are simple concepts but Promises are a form of monad, and just watch people try to explain what a monad is, it’s not straightforward. And to that the fact that async/await syntax looks very different than promise chaining, but they do the same thing
11
u/Defruitpear Mar 12 '26
Asynchronus code is confusing af when you start, but it becomes simple after a few explanations honestly
2
u/beavis07 Mar 12 '26
I would say it’s less about one feature or another - it’s more about figuring what not to do.
JS/TS can be wonderfully elegant done right. It can also be an unreadable, obfuscated nightmare done wrong.
Learning which affordances of the language to ignore and which patterns to avoid is by far the longest leaned lesson
2
u/Forward_Signature_78 Mar 12 '26
I don't know if it's the hardest thing to learn, but probably the most important thing to understand is how functions and closures work.
25
u/TheZintis Mar 12 '26
On my time teaching, the hardest regular topic is the "this" keyword. It's not very intuitive, and most students haven't done that much or any oop. I have the teach of it down ok, but it's still challenging to grasp.
4
u/Jealous-Cloud8270 Mar 12 '26
When I was learning JavaScript for the first time (as someone relatively new to programming), Promises and asynchronous programming in general really confused me. I was using the book Eloquent JavaScript (my favorite programming book ever, BTW), and even after going through the chapter on async and finishing the rest of the book (with lots of practice) I just didn't get them well enough. It was only after using them in actual projects when I slowly started to understand them
3
u/jax024 Mar 12 '26
Probably the object model, in react, what causes a rerender from creating a new object (often arrays)
3
u/peterlinddk Mar 12 '26
Judging by most of the posts in r/programmerhumor, type coercion is the hardest concept to understand in JS ...
But honestly, I don't think there is an universal "hardest concept to learn" that goes for everyone - it very much depends on where you come from, what you have previous experience with.
Back when arrow functions were the hot new thing, a lot of my older co-workers found them incredibly hard to understand, except those who came from Python, where lambdas had been used for years. And I have seen a lot of junior-programmers struggle with learning array methods like
.foreach,.filter,.mapetc - but I've also experienced a group of students who had never seen regular for-loops, understand them immediately. I have struggled immensely teaching Java-programmers how to use set and get properties, and they just don't get why they shouldn't just continue writing set and get methods for every single attribute.It is always easier to understand something if you don't expect it to behave different than it does!
3
u/Squigglificated Mar 12 '26
References in general. More specifically which data types are passed by reference and which are passed by value. Knowing how to avoid unintentionally mutating something. Learning about shallow and deep equality, which built-in methods returns shallow copies, and how to safely copy objects and arrays (thankfully a non-issue with structuredClone).
I spot these things automatically now, but it took a while to learn.
3
u/Reeywhaar Mar 12 '26
Why do we need 1034 packages installed 897.45mb in total for a basic one page website, to be honest I still do not understand
1
u/gojukebox Mar 13 '26
Yield
4
u/ExpletiveDeIeted Mar 12 '26
Raw promises still give me a headache. I thank god for async await.
Regex back references. But that’s prob not js specific.
2
u/jojubluch Mar 15 '26
Prototypes :')
1
u/Impressive-Usual-938 Mar 15 '26
closures took me way longer than it should have. not because the concept is hard but because every explanation i found started with the academic definition instead of just showing a real example of why you'd want to use one.
1
u/JebKermansBooster Mar 12 '26
Front-end/JSX. How the fuck does that sorcery work?!
0
u/PretzelPrairieDog Mar 17 '26
Everything about JS is awful from an application development point of view.