It is possible to access vasiables from JavaScript by just adding the "$App." prefix to the variable name.
Look at this sample: 


SetVar [myvar] "Hi!"

BeginJS

  alert($App.myvar);

EndJS