DEV Community

Yaphi Berhanu
Yaphi Berhanu

Posted on

What are your biggest struggles in learning JavaScript?

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)

Collapse
 
jess profile image
Jess Lee

Callbacks and promises!

Collapse
 
le_newtype profile image
Nicholas ―M―

These can be difficult for me sometimes too!

Collapse
 
ben profile image
Ben Halpern

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.

Collapse
 
binaryforgeltd profile image
Bart Karalus

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.

Collapse
 
binaryforgeltd profile image
Bart Karalus • Edited

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'.

Collapse
 
ben profile image
Ben Halpern
Collapse
 
binaryforgeltd profile image
Bart Karalus

Good one Ben! Or how Shakespeare would say... "This... or not this?"

Collapse
 
daveblythe profile image
Dave Blythe (he/him)

this++

Collapse
 
danwright profile image
Dan Wright

_self

Collapse
 
yaboibrooks profile image
Adincath • Edited

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.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

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.

Collapse
 
inceptioncode profile image
Darrell Washington

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.

Collapse
 
kayis profile image
K

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.

Thread Thread
 
inceptioncode profile image
Darrell Washington

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.

 
kspeakman profile image
Kasey Speakman • Edited

Ironically, FP-ness is general and transfers even to OO languages. E.g. JS's Array.map, reduce, filter, lambdas, etc.

Collapse
 
sreedharbukya profile image
Sreedhar Bukya

asynchronous nature in debugging and this

Collapse
 
laijoann profile image
Joann

ASYNCHRONOUS. Y E P. 100%. When I hopped from Java to JS, the fact that JS is asynchronous is definitely the biggest trip up.. 😅

Collapse
 
janguianof profile image
Jaime Anguiano

same here : )

Collapse
 
sephcoster profile image
Seph Coster

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 which this 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.

Collapse
 
perrydbucs profile image
Perry Donham

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

  • 9 comments asking why you are using an IIFE
  • an argument regarding the use of the keyword var
  • 14 reasons you should be using Python instead of Javascript
  • a correction for a typo in one of your four lines
  • a correction to the correction that insists the typo is intentional and within spec (with a link to a Fiddle to prove it)
  • a complete refactoring of your four lines into ES8 to show how much simpler it will be
  • the history of foo, bar, and baz

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!

Collapse
 
yaphi1 profile image
Yaphi Berhanu

This is hilarious and true. Very well put.

Collapse
 
ben profile image
Ben Halpern

Beautiful description 😂

Collapse
 
zzzzbov profile image
Timothy

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.

Collapse
 
perrydbucs profile image
Perry Donham

I think that you just made my point 😉

Collapse
 
zeropaper profile image
Valentin Vago

Yepa.

You just described the separation of concerns concept fairly well.

Thumbs up!

Collapse
 
albertdugba profile image
Albert

You're damn right

Collapse
 
fallenstedt profile image
Alex Fallenstedt

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.

Collapse
 
kav2k profile image
Alexander Kashev • Edited

Choice.

With modern Javascript being what it is, the question of what to learn becomes more problematic than how.