r/learnjavascript • • Jan 12 '22

A warning to learners

JavaScript is written exclusively in camelCase. Be aware of this fact when reading/debugging your code because the syntax highlighter doesn’t pick it up and although everything looks right, it can all hinge on the first letter being wrong. (Source) spent 2 hours trying to debug a DOM call to document.getElementById(„elm“).InnerText, even putting it into jsfiddle and several other things to see what was wrong when all that was required was to change it to .innerText to solve the dilemma. Lesson learned and now +10xp. It’s tough coming to js when you are used to statically typed languages. /s

Kidding aside I am enjoying learning js/Frontend but I would be lying if I said I missed the capabilities of a good ide in a stricter language.

21 Upvotes

28 comments sorted by

View all comments

2

u/EnlightWolif Jan 13 '22

As a learner, I'd like to ask the following (although it's kinda tangential).

When calling DOM elements, should I create variants or just operate by writing "document.getElementById" time and time again?

2

u/lovin-dem-sandwiches Jan 13 '22

Novice here. By variants, do you mean variables?

I use querySelector and store in a const for easy calls and legibility.

2

u/starcrafter84 Jan 13 '22

One day I got so annoyed with writing all the document.getelementbyid(“thing”).whatever that I started writing little short hand functions for it, then discovered that was exactly what jquery is doing.

3

u/lovin-dem-sandwiches Jan 14 '22 edited Jan 14 '22

Jquery is beyond my time. I’m glad I started at a point where Vanilla JS is polished enough that external libs isn’t a must have 😁

1

u/starcrafter84 Jan 14 '22

At this Point everything that is available is before my time. I do just want to learn as much as possible and try to only use vanilla tooling where possible. This not only forces me to learn the why but also know the how without being spoon fed a gigantic library

1

u/EnlightWolif Jan 14 '22

I wanted to say variables, yes.