Var vs. let or const - Node v18+

The node course was developed using node v8.9.1, and Mosh uses var = but it seems that the current LTS of node (v18.13.0 at this time) allows for let and const.

What is the current preferred method, var or let?
How does this affect scope(s)?


Better to use const and let instead of var where you can. Var is function scoped not block scoped. Other programming languages use block scoped variables. It is one of those JS quirks / inconsistencies that ES6 set out to fix. Const and let are both block scoped and can help minimise unintended behaviour and inconsistent results in your programs.