Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@black-kite
When I use "const" I'm making a promise: you can change this, but you probably shouldn't. And you can expect this thing to always have this value
Take pi. You can technically change it: maybe you don't want to stick to flat 2d surfaces but for most cases it's a constant value of 3.14 and const reflect that; at writing\compile time you know what that is. And you probably don't want to touch it.
Now, take the result of some kind of operation, like a fetch from a server. I did never reassign it, but why should you expect this value never to change? It's some values from some external source I don't even know, you could drop there whatever and still be fine.
With prefer-const you're forcing me to declare it with const -that is, making sure nobody changes it- when there's no actual requirement to do so.
Which defeats the whole point of const, that is to communicate "this is a constant value and should be treated as such"
This guy gets it https://jamie.build/const -
I say let's deprecate const & let and just use var everywhere so we don't need to have arguments about memory allocation slot pronouns
-
@ostream here you go:
const constants = {};
Object.defineProperty(constants, 'PI', { value: Math.pi(), writable: false })
Sometimes I feel like I'm a dumb worthless retard, a pathetic excuse of an ape with no reason left to live this pathetic farce of a life.
But then I remember there are people who enforce "prefer-const" in their codebase, and there I realize that if those people are alive and well I must deserve something too, and thus I hold on.
I will outlive you. I will remove that dumb directive from your linter config and I will commit that to master. I care not what happens next.
rant
linter
const
prefer-const
javascript