All variables having at least one capital letter, wherever located, are global variables. So, %Myvar, %MyVar, %myvaR, %mYvAr etc. are all global variables. In a Javascript you must refer to them using global statement : global("MyVar").
So,
A1 Variable set [%Myvar To: Hello Do Maths:Off Append:Off]
A2 Javascriptlet [ Code:alert(global("Myvar")); Libraries:Auto Exit:On Timeout(Seconds):45]
will show an alert saying Hello.