Var 3/3
Why var is not used now
Due to hoisting and the global scope declaring variables with the var leads to so much confusion in the code. If we change the value of a variable at just one place intentionally the var will change that value all over the code. It will create so many unexpected results in our code.
Swipe to start coding
Hoisting is used in the following code and this code does not give any error but not a preferable approach. Your task is, using only the let keyword, to re-arrange the variables in the code and display all the variables.
Solución
Summary:
- The
varis an alternative to theletkeyword in JavaScript. - Variables declared with
varcan be accessed before the declaration. - The
letandconstdo not allow hoisting butvardoes. - It is not a good practice to use
varinstead we should use let.
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Can you explain what hoisting is in JavaScript?
What are the main differences between var, let, and const?
Why is using let or const considered better practice than var?
Genial!
Completion tasa mejorada a 2
Var 3/3
Desliza para mostrar el menú
Why var is not used now
Due to hoisting and the global scope declaring variables with the var leads to so much confusion in the code. If we change the value of a variable at just one place intentionally the var will change that value all over the code. It will create so many unexpected results in our code.
Swipe to start coding
Hoisting is used in the following code and this code does not give any error but not a preferable approach. Your task is, using only the let keyword, to re-arrange the variables in the code and display all the variables.
Solución
Summary:
- The
varis an alternative to theletkeyword in JavaScript. - Variables declared with
varcan be accessed before the declaration. - The
letandconstdo not allow hoisting butvardoes. - It is not a good practice to use
varinstead we should use let.
¡Gracias por tus comentarios!
single