+ 3

what is the difference between using var in js or not ( var a=4 or a=4 )

29th Mar 2019, 5:52 PM
Emma
4 Respostas
+ 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
31st Mar 2019, 7:18 AM
Darcy Dev
Darcy Dev - avatar
+ 4
Without using "var", "a" will be a global variable.
29th Mar 2019, 8:56 PM
Solo
Solo - avatar