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.
Soluzione
Summary:
- The
var
is an alternative to thelet
keyword in JavaScript. - Variables declared with
var
can be accessed before the declaration. - The
let
andconst
do not allow hoisting butvar
does. - It is not a good practice to use
var
instead we should use let.
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Awesome!
Completion rate improved to 2
Var 3/3
Scorri per mostrare il menu
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.
Soluzione
Summary:
- The
var
is an alternative to thelet
keyword in JavaScript. - Variables declared with
var
can be accessed before the declaration. - The
let
andconst
do not allow hoisting butvar
does. - It is not a good practice to use
var
instead we should use let.
Grazie per i tuoi commenti!
Awesome!
Completion rate improved to 2single