Ok so i’ve been trying to learn javascript for like months now and i just cant get it to stick. ive watched so many youtube videos, obviously tried here, did the codecademy.com stuff, tried jsexercises.com, odin project as well and nothing is working for me. Are there any other ways to do it? I am trying to do at least 1 hour a day, I work as admin in a company but my cousion who’s a developer makes a ton of money and I want to get into it.
Thing is I was actually starting to feel like I was getting it a little bit, like I understood what a function was and its purpose, but every single time I try to apply it I literally just forget what to write. It’s like I know the theory of WHAT to put, but when I try to write it, my mind turns into mashes potatoes.
Did anyone else feel this dumb when they started or is it just me. How did you lot get through it??
I still feel dumb with Javascript as I am a slow learner. But I have to think JS in my own way. Here is some of my findings (and opinions) that have helped me understand Vanilla JS at least a bit.
1 The chicken and egg trap. The DOM must be present before you can do something with it.
2. Double Listener traps. Double listeners may cause trouble. Event delegation reduce the risk.
3. If you set a variable inside a function, you cannot reach this in another function
4. Long function trap. Break up a long function into several small functions.
5. Long if else… Switch case is sometimes easier to read.
6. Avoid loops if possible. Can make the code slower and harder to debug.
7. Use fetch() instead of XHR
8. One trap is to try reassign const. Use let instead if you should change it later.
9. The SEO trap. Long javascript is recommended, but it is easier to split up into several .js
10. Move code to the backend if it is possible (PHP, Python or whatever)
11. JSFiddle is a good tool for testing and learning. https://jsfiddle.net
12. And (somewhat outdated) https://www.w3schools.com/js/default.asp is still valuable.
If I’m trying to learn something new, I find that the most effective way for me is to think of a project and get coding it. I learn far more that way than going through endless exercises. Even when I’m familiar with a language I still find myself looking up function names, parameter lists etc. but I’m not usually doing this every day, and don’t use anything that’s got intelligent prompting.
Step 1: Forget language.
Step 2: Reduce problem to as fine a resolution in a manner that makes sense to a computer as possible. (Your goal is a list of incredibly small steps. “Add a to b” level of steps.)
Step 3: Convert Step 2 to language, by line.
Step 4: Google the specific problem you’re having with each line in Step 3.
That’ll get you 99.5% of the way to having functional code. Will it be the best? Will it be the fastest? No. But it’ll work, and you will probably have learned individual bits here and there. Repetition will carry you towards streamlining (“Okay, i’m going to need a loop, i know what that looks like…”)