Ecmascript 6 let or var? | Sololearn: Learn to code for FREE!


Ecmascript 6 let or var?

Why using let in example code instead of var to declare variables?It gives error in code playground try.

8/27/2020 8:26:16 PM


3 Answers

New Answer


I don't get an error. The reason for using let is that it behaves much more consistent compared to var. In general it's cleaner and also more efficient to use let. var is only needed seldom when using ES6. Here's some further information:


Could you share the code? Otherwise it will be pretty hard to guess what caused the error...


Only who learn javascript course can answer this one.But if you have an idea Aaron Eberhardt about ecs6 use of let and var in general for example: let name = "Ahmad"; console.log(name);