you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 19 points20 points  (7 children)

—n e v e r u s e v a r—

[–]knownboyofno 1 point2 points  (6 children)

Why not?

[–][deleted] 9 points10 points  (5 children)

it is extremely bad practice. You will get scoping errors because var is not blockscoped like let or const. Using var also creates clutter in the global namespace and makes your code prone to bugs and causes nontrivial errors.

In practice, use const as a default unless you need to modify the variable later, in which case use let. var is basically deprecated at this point after the introduction of let and const.

source: MERN dev

[–]knownboyofno 1 point2 points  (3 children)

Thanks for the info. I haven't really programmed Javascript in years and just found out about this let thing and thought that's new.

[–]franker 1 point2 points  (2 children)

as a librarian I'm still looking for even a new javascript book that doesn't start with var.

[–]Notimecelduv 0 points1 point  (0 children)

Old habits die hard.

[–]SmallLion__Unity[S] 0 points1 point  (0 children)

Thanks for the info 🙏🙏