Tech
var, let, const — and why JavaScript changed its mind
When I started learning JavaScript, I kept seeing the same advice: use let and const , don't use var .
Usually it came as a rule, not a reason. And a rule you don't understand is a rule you forget — so I went looking for the why .
It turns out var isn't just old-fashioned. It's broken in three specific ways, and let and const exist to fix exactly those three things.
Here they are.
Problem 1: var lets you redeclare the same variable
Watch this:
var ...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to