JavaScript is a scam

There’s a setting to make globals accessible in functions with the “global” keyword. Bit “dangerous” though.

If you need ‘globals’ and want to make it explicit that you are actually using a variable as a global, just make a static field…


class Stuff {
   public static $USERNAME;
}


Stuff::$USERNAME = 'Riven';

echo Stuff::$USERNAME;

function abc() {
   echo Stuff::$USERNAME;
}

abc();