A *very* seasoned software engineer, I wrote my first basic game, a lunar landing game, in Basic in 1969. Currently I am doing web development in Ruby on Rails, JavaScript, Elm.
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.
A *very* seasoned software engineer, I wrote my first basic game, a lunar landing game, in Basic in 1969. Currently I am doing web development in Ruby on Rails, JavaScript, Elm.
From early on Jelena enjoyed handling challenging obstacles and tasks. Today, she's a passionate problem-solver that loves to share her knowledge and experience.
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 thatconst 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?
No where near as well as Kyle does: github.com/getify/You-Dont-Know-JS...
Thank you.
Came here to make literally these two comments!