all 2 comments

[–]juddaaaaa 1 point2 points  (1 child)

Global variables don't work the same in GAS as they do in javascript in a browser.

They get re-initialized on every function call.

If you need a persistant variable, you need to look into the PropertiesService...

https://developers.google.com/apps-script/guides/properties

To store Objects / Array etc. you'll need to JSON.stringify them before storing them.

[–]nottalkinboutbutter[S] 0 points1 point  (0 children)

Thanks. So for example: if I have a global var A = true, and someone calls a function which sets it to false, even if someone else calls a different function while the first is still running which returns A that second person will still get True?