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.

Top comments (65)

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
 
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
 
yaphi1 profile image
Yaphi Berhanu

This is hilarious and true. Very well put.

Collapse
 
ben profile image
Ben Halpern

Beautiful description 😂

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
 
daveblythe profile image
Dave Blythe (he/him)

this++

Collapse
 
binaryforgeltd profile image
Bart Karalus

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

Collapse
 
danwright profile image
Dan Wright

_self

Collapse
 
le_newtype profile image
Nicholas ―M―

Kind of silly, but sometimes knowing what some things are, but not knowing what they're called can be difficult or disheartening, especially in an interview or skill-building situation. Some examples that I've personally struggled with include, but are not limited to: closures, hoisting, various design patterns (module vs constructor vs API vs factory vs x100000 other ones), etc.

That feeling of inadequacy, followed by a realization that I actually knew what was being discussed all along (coupled with an "Oh, there's a name for that?") can take a while to shake off.

It can also be hard to discern "Is this a programming thing?" or "Is this a insert framework context here thing?" since JS is prone to having multitudes of vocabulary words being tossed around at any given time.

Collapse
 
inceptioncode profile image
Darrell Washington

I definitely agree and feel your pain on that one. I'm a young developer and I often times leave interviews thinking, "I just know how to code I don't know all these technical terms." It's so frustrating and I feel slow or lost at times.

Collapse
 
yaphi1 profile image
Yaphi Berhanu

That's one of the most frustrating things when you knew a topic all along but you just didn't know one of the terms for it.

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

 
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.

Collapse
 
mohannad profile image
Mohannad Najjar

I was going to say this and scopes, but since it's mentioned already, I will say: Compilers and Presets and Browser Support!

There is so many to figure it out, TypeScript & Babel & ES2015 & ES2016 & ES2017 . and the whole ECMAScript 6 Compatibility with browsers, See This Compatibility Table for example.

Collapse
 
eldelshell profile image
eldel$hell

Not sure for how long you've been working with JavaScript, but believe me, today, it's a bliss since most browsers (specially MS, although Safari is the new MSIE6) put their shit together. Just a few days ago some potential client kind of dropped the bomb about supporting MSIE-8 and all the nightmares came back.

Collapse
 
fezvrasta profile image
Federico Zivolo

If a client asks to support IE8 I just make him pay its support as a brand new project. That's it.

Thread Thread
 
fabth profile image
Mr Dude

We do exactly the same, old and non standard browsers are quoted as an extra and separate part of the project.

Collapse
 
willluce profile image
William T Luce • Edited

Lots of good answers here, but I'd like to add that, due to JavaScript's history, people don't learn it the way they do other languages.

In my experience, when people pick up languages like Python or any of the C family, they grab a book and work through it. Along the way, they're learning how the language works and the ins and outs of how to solve problems using that language. So, things like syntax, common patterns, and the quirks of that language are naturally introduced.

With JavaScript though, new people just start grabbing at tutorials that show them HOW to do some specific thing or HOW to use some new framework. At no point are they learning actual JavaScript.

Learning React, Angular, Ember, Lodash, or any other plug and chug tool is not learning JavaScript. Going through a "What's new in ES6!" blog post is not learning JavaScript. Even learning Node is not learning JavaScript.

Read You Don't Know JS, all of it and actually LEARN JavaScript.

Collapse
 
yaphi1 profile image
Yaphi Berhanu

You know, I never thought about it, but this makes so much sense. Fantastic points.

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
 
fezvrasta profile image
Federico Zivolo

DOM APIs are probably the hardest part. You never know all the nuances of each of those methods...

For instance, just yesterday I found a bug in my library because I used .offsetParent to get the first "positioned parent node", and I discovered that this property will give me the nearest "table" element if no positioned parents are available...

Collapse
 
lindakatcodes profile image
Linda Thompson

One: I can follow along with a tutorial no problem, understand what they're saying, write it all myself (instead of copy/paste) and all makes sense. Go to apply it on my own, either starting with a new project or adding it to something I was already working on - and I get a type of paralysis. Applying it on my own, without someone walking me through it, is regularly a huge hurdle for me. It's almost like my brain just isn't really absorbing it. Or so much of the other code (their styling and html and such) is taken care of that when I mix in the new stuff I don't know how it plays with everything else, because I didn't have to think of that in the walkthrough. I normally work it out and I'm fine, but it often stops me for awhile.

Two: Setting up my own dev environment. This still gets me almost every time, though I'm getting better. When you're learning the language so much is guided and focused on the actual language and on using tools that handle most of the other stuff for you. Which is great, in it's way....it's just hard when you go out on your own to really find a flow that works and lets you see what you're changing as you go.

Collapse
 
garyfalkland profile image
Gary Fitzwater

As for point one exactly how I feel, I go along with tutorials but when it comes to working on my own I hit a brick wall.

Collapse
 
aswathm78 profile image
Aswath KNM
  1. As a complete beginner ,t he biggest trouble is finding the right guide(which or whose learning path should I follow ???).

  2. Angular or React or Vue???(which front end framework)

  3. ES5 , ES6, ES7 , ES8 ?????(How many things should I learn ???)

  4. Babel , JSX and how many more ?

Collapse
 
tiffany profile image
tiff

I think you use JSX with React anyway. Just HTML in your JavaScript which is a React thing.

Collapse
 
maxart2501 profile image
Massimo Artizzu

Declaring a "class" with a function, and adding methods dynamically with this weird prototype object. How weird!

But really, learning JavaScript has been, fortunately, quite easy forward for me. I'm kind of puzzled of all the issues about it.

Collapse
 
fred_amare profile image
👑 Fred Amare

Callbacks and closures

Collapse
 
tiffany profile image
tiff

The easiest way I can tell you about what a callback is: it's just a function passed as a parameter to another function. jQuery uses callbacks a lot. Still trying to wrap my head around closures.

Collapse
 
ben profile image
Ben Halpern

Callbacks were impossible for me to wrap my head around when I was first getting into JS. Beforehand I had mostly been coding in Ruby and things are just not done that way (well, asynchronous programming in general is not really a Ruby things)

Thread Thread
 
fred_amare profile image
👑 Fred Amare

Same as me... I started my coding journey with python. What a beauty that language is 😍

Collapse
 
fred_amare profile image
👑 Fred Amare

Ha! closures...

Thread Thread
 
tiffany profile image
tiff

Right?

Collapse
 
eldelshell profile image
eldel$hell • Edited

Been using JS for... 17 years or so... and I still struggle with the different ways other developers find ways of doing stuff. I'm talking from formatting (2/4 spaces, double/single quotes) to OOP/FP/ES6 or weird patterns like jQuery plugins or JSX files.

Other languages (C/C++/Java/C#/Python/Go) seem to be teach on a more standard form and it's easier to read code written from a guy on the other side of the world from 10 years ago. You can't even find two JS code bases with the same formatting for documentation.

JavaScript developers really really need to get their shit together and follow some sort of standard. PEP, javadoc and go-fmt are great tools to look into.

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
 
val_baca profile image
Valentin Baca
  • Closures and 'this'
  • looping over properties
  • browser nuances
  • browser support. All these neat new features arriving in JS that I don't know if I can use or not
  • libraries that use .map(index, item) vs .map(item, index) (The latter is the better BTW)
  • var functions vs function declarations
  • naming conventions clashing between JS, CSS, and AJAX (camelcase, hyphen-case, and lowercase respectively)
  • funky auto-casting
  • double trouble 0.1+0.2 != 0.3
  • null, undefined, and undeclared
  • === and !==
  • "Optional" semi-colons
  • Frameworks that multiply like Tribbles

Each one on it's own is an inconvenience and every language has its issues. But put all of these together and it makes coding a terrible experience.

Javascript really is the English of programming languages. It's ubiquitous and it's surprising how much gets done in it, but it's not a beautiful or good language by any stretch of the imagination.

It makes me wonder everyday why Node.js was/is a thing that grew beyond just an April Fools joke.