JUCE Javascript has no local variables?


#1

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

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

#2

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;
}

x();
Console.print(y); // undefined

#3

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