global variables

ManuTheFrog's icon

Hello everyone.

To have a global variable in Javascript, it is just needed that it is declared before and outside of functions we write, right ?

But will this global variable be global to the patch in which the [js] object is nested as well ?

thx
Manu

Nat's icon

If you create a variable outside functions (in global code) it will be global to the JS object that loads your code. If you want a global that is global to all JS objects and max, check for the Global object in the Javascript documentation.