re: Do's and Don'ts for Javascript Newbies VIEW POST


Formatting code: Prettier is something folks should know about; it integrates with ESLint quite nicely, and can be added to most code editors pretty easily.

let, const, and var: In the examples given, doing let container = document.getElementByID('SomeId') is more of a signal to the developers that it will somehow be changing. In fact, the variable itself never changes, it still points to the same DOM element object, which is changing internally. This can be hugely confusing to realize that const container = document.getElementById('SomeId') ; container.innerHTML = "Hello" will work exactly the same way. Kyle Simpson (@getify) has a great discussion on this in YDKJS.

Also, don't completely discard var from your vocabulary as it still has uses; instead understand when and where to apply it.

The adage "use const until you can't" is a good one if everyone understands that.

Great article!


I come to the comments looking for an explanation about the let/const and why we should use them instead of var.

Can you clarify the difference for me?


Came here to make literally these two comments!

Code of Conduct Report abuse