Problem with javascript variables "ReferenceError: variable not defined"

Support
  • I don't need help with this, just want to share a solution I found on the Russian side with the English side. Not sure where else to post—Support seemed like the right spot.

    If you're having trouble with the "ReferenceError: randomVariableHere not defined" popping up in the logs when trying to work with JavaScript, the problem could be due to your BAS variable naming conventions or how you format your variables name. In BAS, if you are going to put variables into the JavaScript(browser) module, you need to use the all-uppercase, underscore-separated format (commonly known as screaming snake case) rather than camelCase.

    For example, if you declare your variable in BAS this way you will get a reference error:

    wrong way finished.png

    But if you declare your variable like this your js code will work in the browser:

    right way finished.png

    I hope that clears up any possible confusion for others that may be experiencing the same problem I was. Please feel free to add anything contributing and keep on keepin on.

    reference: Original Russian thread

    Reference (google translated to English)

  • @Megadarren88-0

    This is not a bug, this is a feature.

  • @sergerdn I'm not saying its a bug, I'm explaining to other people how to do it properly if they are facing the error. Did you even read the post 🤦‍♂️