I was doing a few tests and I'm just curious about what's been happening. I've been declaring variables in .js files with:
var someVariable = someValue;Without the var keyword, someVariable would be undefined. When I went into the event editor and put these two lines in two different script blocks:
var anotherVariable = anotherValue;
There was an error saying that someVariable is not defined. I expected that. It worked fine when the two lines were in the same script block. However, when I split the lines into two blocks again and removed the var keyword:
anotherVariable = anotherValue;
The console logged anotherValue! How are objects and variables in the event editor handled? I'm really confused about how anotherVariable could both be declared without var without being undefined and be used in other script blocks in the event editor.
var someVariable = someValue;Without the var keyword, someVariable would be undefined. When I went into the event editor and put these two lines in two different script blocks:
var anotherVariable = anotherValue;
Code:
console.log(anotherVariable);
anotherVariable = anotherValue;
Code:
console.log(anotherVariable);