JS in sololear is latest version or older? What do we use often VAR or LET and CONST?? I Have VAR is no longer used is it true?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JS in sololear is latest version or older? What do we use often VAR or LET and CONST?? I Have VAR is no longer used is it true??

Since latest version of JS developers aren't using VAR in JS and they have upgraded to using LET and CONST to declare statement in JS, is it true?? If so then sololearn is teaching what methods and why they aren't upgrading to latest version of JS and start using LET and CONST in place of VAR for declaration.

3rd Dec 2022, 3:23 AM
Veeresh Angadi
Veeresh Angadi - avatar
7 Answers
+ 5
SoloLearn considers those users whose device don't support latest version of JS,. I can still occasionally find some user who asked why they can't run other people's codes which were written in latest standards. For web users it's easy, just need ro update their browser. Some mobile devices can no longer update their web component due to device age.
3rd Dec 2022, 4:00 AM
Ipang
+ 3
VAR, LET and CONST are the invalid syntax in JS. Don't believe? You can try to run VAR i=1; in Code Playground JS to see what you can get.. ---- Code Playground does not control which JS version to run, it's the JS of the user device that run the Code Playground web codes. If you want to support very old device JS, you can use var, however it's already year 2023, most devices support ES6 (ECMAScript 2015). When exactly will we be able to use ES6 with confidence, if not now? ES6 helps to build better JS codes, we should always use it.
3rd Dec 2022, 4:16 AM
Calviղ
Calviղ - avatar
+ 3
Calviղ , Veeresh Angadi var, let and const works. VAR, LET and CONST I've never heard of in js... javascript is case-sensitive.
3rd Dec 2022, 4:29 AM
Bob_Li
Bob_Li - avatar
+ 2
Lochard , you are right. But the general consensus is to use let more and var only if you need to. var works like a global variable, convenient but risky. let is introduced to provide a more constrained option. This is deviating from the topic, though. Which is don't use caps lock when typing let, var or const....😁 surprise result with var: https://code.sololearn.com/W04nytFjO3Vw/?ref=app
3rd Dec 2022, 2:39 PM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li You are right. I was just describing it. We could declare with let before the if block in my example if we want the variable accessible both in and after the if block.
3rd Dec 2022, 2:32 PM
Lochard
Lochard - avatar
0
var has a wider scope than let and const. Let's say, we define var v, let l, and const c in a if block in a function. Only v could be accessed after the if block. None of them would be accessible after the function.
3rd Dec 2022, 11:03 AM
Lochard
Lochard - avatar
0
Lochard wider scope have drawbacks, though. It is more prone to name conflict, specially in long codes. The limited scope of let is more manageable and less prone to surprise bugs.
3rd Dec 2022, 12:00 PM
Bob_Li
Bob_Li - avatar