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
-
buitrung3066yDo not blindly "Find & Replace" in the childish way. A simple blank after "var" (Find: "var ") can do you the appropriate favour. That's just to say in this case. There're many ways to do difficult replacements. Remind that you have to be sure of what you're about to do before you actually do it.
-
@buitrung guess I'm a little less functional after being up all night. You're right tho:)
-
Voxera115856yAlso, just because var is bad practice today does not mean switching to let will work.
Suddenly you will find that the code depends on the behavior of var and breaks with let ;)
Personally I try to use const as much as possible now a days and only use let when there are no better option. -
@fredisinbed
replace = behave the same way
No
Replace = should not use var
True
Replace = replace every var with let like fucking idiot op
Absolutely no -
@ganjaman I think most people with some knowledge of js would go for the second option. But then again, replace all can lead to fun errors x)
-
Voxera115856y@sunfishcc sorry for the late comment, missed this response.
Babel does this to make sure the code works on older browsers.
But it should, and probably does, wrap every let in a function unless t already is.
That keeps the scope of the let while using a var.
I used hat technique when writing library code to make sure not to pollute the global namespace.
But using functions create very strange and non intuitive code, using let and having babel transpile it means you do mot have to deal with such hard to work code.
Related Rants
Improving an old JS code, replaced all 'var's with 'let's. Previous guy wrote a comment above his variables, which is now saying:
"letiabes"
rant
js