What are/were your biggest struggles in learning JavaScript?
This question can refer to specific code issues (like working with arrays) or learning issues (like following a tutorial but not remembering afterwards).
I'd like to hear it all!
Also, if you're more experienced, but you still remember your struggles with JS, feel free to chime in.
Oldest comments (64)
Callbacks and promises!
These can be difficult for me sometimes too!
Keeping up with patterns and best practices as the language and ecosystem evolves is a struggle for me. Other environments seem a lot less likely to change from under my feet.
That is very true.
At some point I have realised how flexible this language is and the amount of surprising ways I have seen people using it so far only made me want to finally find those best practices for me.
Back in the days, for me personally the most confusing thing was what 'this' actually is.
When I speak to many less experienced devs today, the most frequent struggle mentioned are 'scopes' and 'closures'.
this
Good one Ben! Or how Shakespeare would say... "This... or not this?"
this++
_self
I also have issues keeping up with best practices. In ReactJS, I started with the create-react-app boilerplate. As soon as I got something concrete going for an app, my co worker was adamant that React Boilerplate because it's super efficient and ASYNC REDUCERS AND SAGAS WOW!
This compounds because React is just one part of the entire JS ecosystem and even just keeping up with it can be hard.
My entire dev career has been web, and I am really tempted to bash JavaScript here. :)
I will say that JavaScript has a lot of quirks which can bite you. Nowadays, a lot of libraries or preprocessors help by giving expressions of code which are more robust while staying on the happy path. But there continues to be a lot of churn in tooling and libraries around JavaScript to smooth out rough edges, especially given the (web) platform's popularity. So don't wear yourself out. I've put stuff into production on a lot of different platforms from pure JS to Angular that were "the new thing". Mostly to disappointment that the same problems were just in different places. Nowadays, I try to avoid writing JS code. For web UIs, I have been using Elm and my experience so far in maintaining its code has been very positive.
I think Elm will be the norm soon. I haven't had a bad experience with it yet either. Even though I haven't used Elm for to long, I can't help but feel it's just the permanent way to go. I can't wait for it to be everywhere.
Can't see this happen.
Elm is awesome, but it's also rather different and self contained. Many (JS) devs sadly just don't like FP.
Yeah, I understand your point FP to me is great but I just started programming and didn't like learning OOP with JS. So it was easy for me to switch paradigms or practices a little. Everyone has there preferences though.
Ironically, FP-ness is general and transfers even to OO languages. E.g. JS's
Array.map
,reduce
,filter
, lambdas, etc.asynchronous nature in debugging and this
ASYNCHRONOUS. Y E P. 100%. When I hopped from Java to JS, the fact that JS is asynchronous is definitely the biggest trip up.. 😅
same here : )
When first starting out as more of a hobbyist one of the first things I struggled with was how best to use objects and the object structure to store and use data. When to use OLOO vs. a class-like structure to properly scope functions, when to use prototypes, etc. Much of this has been "figured out" or at least made easier in the latest versions of ECMA which is nice.
Working with promises / async and chaining multiple things together to ensure state came together properly (in the jQuery days) and you didn't get "undefined" for your variable that logged just fine in the console was the next annoyance. Abstractions for these are pretty high quality now and somewhat easier to use but I definitely recommend gaining understanding before using otherwise it will bite you eventually :)
this
(as has been said) is also an issue for me. Can still bite but at least I know to think "hey whichthis
is this?" now.Testing. Testing is super important but all the frameworks out there do it slightly differently and figuring out how to mock async / nested / imported stuff from scratch can be super hairy and difficult. I would still kill for an awesome tutorial on JavaScript testing practices. I wish I had started my testing discipline earlier so I had better muscle memory here.
Tutorials and stackOverflow. For some reason Javascript tutorials often start with "In this tutorial we will write a simple ..." and, 12,000 lines later you can't remember what it was you were trying to learn.
And stackOverflow...OMG! Ask a simple question on SO like "Hey, these four lines of code are in an IIFE, where is variable foo visible?" and you'll get
New JS programmers spend a lot of time in the magical incantation stage, copying and pasting random code from the web that they hope will run correctly but that they can't explain how it works. Some never escape it!
This is hilarious and true. Very well put.
Beautiful description 😂
As a 100k user I'm certainly biased, but I don't agree with this at all. What it sounds like is confusion over what Stack Overflow actually is.
It isn't a place to learn new languages like JavaScript. It's not meant to train people on languages or provide tutorials. It's meant to find specific answers to specific questions.
And with that, if someone asks another "I don't know how IIFEs work" question, I generally dupehammer them to "How do JavaScript closures work?", and scold them for not having done enough research.
I think that you just made my point 😉
Yepa.
You just described the separation of concerns concept fairly well.
Thumbs up!
You're damn right
The biggest struggle I had was the transpiling craziness that is modern JavaScript. I found that I had to spend a decent amount of time setting up a transpiling environment just to start coding.
Choice.
With modern Javascript being what it is, the question of what to learn becomes more problematic than how.