+ 3
what is the difference between using var in js or not ( var a=4 or a=4 )
4 Réponses
+ 6
Var a = 4: to create a new variable and assign the value directly.
a = 4: to change the value of a variable(var a; a = 4)
e.g:
var a = 4
a = 5
Console.log(a)//5
+ 4
Without using "var", "a" will be a global variable.