JUCE Javascript has no local variables?


It seems all JUCE javascript variables are global. Is this correct?

for (i = 0; i < 2; ++i)
 var x = 1; // this is global..?


Javascript doesn’t have a block scope like C++, but a function scope (so local functions declared inside variables are only visible in the function:

function x()
	var y = 5;

Console.print(y); // undefined


…however ES6 has let which allows local variables to be declared only within the current block.