Does this line create global variables?
4 answers
first
will be declared as a local variable and the rest will be global.
To fix this, try the following:
var first, second, third, fourth, fifth;
first = second = third = fourth = fifth = "Hello, ";
Or all on one line:
var first, second, third, fourth, fifth = fourth = third = second = first = "Hello, ";
+3
source to share
First will be local, the rest will be global. See this script from the JS Fiddle .
+2
source to share
Yes, this is to declare your variables first:
var first,second,third,fourth,fifth;
first=second=third=fourth=fifth="Hello, ";
Will do the same, except all the variables will be in the expected scope.
You only have a variable declaration with a name first
and four other variables are used without declaring them, so they are global.
+1
source to share