Ecmascript 6 let or var? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Ecmascript 6 let or var?

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

27th Aug 2020, 8:26 PM
HBhZ_C
HBhZ_C - avatar
3 Respuestas
+ 4
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: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
27th Aug 2020, 9:01 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 2
Could you share the code? Otherwise it will be pretty hard to guess what caused the error...
27th Aug 2020, 8:48 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
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);
27th Aug 2020, 8:55 PM
HBhZ_C
HBhZ_C - avatar