learnxinyminutes-docs icon indicating copy to clipboard operation
learnxinyminutes-docs copied to clipboard

[javascript/en] var -> let/const

Open sjrct opened this issue 1 year ago • 4 comments

In the javascript tutorial the var keyword is introduced and used extensively, while let and const are only mentioned briefly under the ES6 additions section at the end. In this day and age, where ES6 is support is extremely common and use of var is essentially entirely been supplanted by let and const, wouldn't it make more sense to have var be the footnote instead?

I can make this change, I just want to see what ppl think

sjrct avatar Jul 11 '23 17:07 sjrct

You have a good idea, but it would be ideal to leave the var because there are still many projects that use it, this is indispensable when learning javascript. We would then have var, let and const

wandrey7 avatar Apr 22 '24 18:04 wandrey7

ES6 which introduced let/const which made var obsolete has been out since 2015, almost a decade. I agree that var is still used plentifully and should be discussed, but I really do think that the primacy should be given to let & const and var should be the afterthought?

sjrct avatar Apr 30 '24 17:04 sjrct

Definitely introduce var, let and const, but if the example is not illustrating var, it should use let.

bartdorsey avatar Jun 21 '24 15:06 bartdorsey

If you introduce someone to a language, you should really teach them how to use it properly. In 2024 "properly" means let/const. var should be mentioned with a legacy warning because it is common to see in code. But it should be noted that this, by now, is a major code smell. It was either not modified in the last couple of years (fair, it might be practically bug free) or it might be written by people not very familiar with the language.

ccoenen avatar Aug 09 '24 21:08 ccoenen