📎 Webclip
let, const, and my view
The post responds to the debate around let and const by arguing for const as the default choice. It distinguishes constant bindings from immutable values, says var is mostly avoided because of hoisting and block-scope issues, and claims let should be used when mutation is expected.
Reading notes#
varis described as largely out of use because it hoists to the top of the current function or file scope and is not limited to block scope.letis presented asvarwithout those two issues, whileconstis presented asletwith constant bindings.constdoes not make objects immutable; it only prevents reassignment of the binding.- The post says beginners often confuse
constwith immutability, and that this should be taught as a binding rule instead. - Dan Abramov’s reasons for preferring
letare summarized as loss of intent, confusion, pressure to avoid redeclaring, and little practical benefit fromconst. - The author argues that
constis useful as a default because it makes the unusual case stand out whenletis used. - The post says intent is not lost, but moved, and that
letcan signal that a value will change. - It compares this idea with Rust, where immutability is default and mutation is marked with
mut. - It also says screaming case can already be used when something needs to be marked as constant.
- The conclusion says it is usually better to follow a project’s conventions and keep code consistent.
