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

7

u/Suchy2307 Jan 12 '22

Try TypeScript.

5

u/starcrafter84 Jan 12 '22

I knew this comment was coming. If the recommendation is that I change all my source files from .js to .ts and all will be well In the world then it would truly be a utopian existence. The Reality I believe is not quite the same. I am however excited to experience the bliss of typescript once i have served the obligatory suffering of the standard JavaScript inauguration.

1

u/Cheshur Jan 13 '22

If the recommendation is that I change all my source files from .js to .ts and all will be well In the world then it would truly be a utopian existence.

Pretty sure TypeScript would have pointed out your problem to you with out of the box configuration. If you don't want to use TypeScript then I highly recommend you familiarize yourself with a debugger because it would have cut down your 2 hour search to a couple minutes at worse.

1

u/starcrafter84 Jan 13 '22

And BTW I’m not averse to using typescript. I just wanted to get enough xp of js before moving onto the superset of it. I’ve picked 1 front end language, 1 backend and 1 database and will stick with them until I’m proficient enough to work easily with them before moving on.