Sorry if this a stupid question, but here goes
So I've been learning Javascript for use with Google Application Scripts for about a year now and slowly but surely am finding my feet.
I tried to help someone with their script on here, and i notice that they declared
var ss = SpreadSheetApp.getActiveSpreadsheet();
at the very top of the script, outside all functions, as a global var.
It got me thinking, that when I write several functions/scripts for a spreadsheet, it might be worth declaring some VARs globally rather than repeating them in different functions.
Before I blindly plough down this path, I thought it best to ask are there any major pitfalls or problems with using global vars in GAS.
Also, are there any major advantages, besides saving a bit of typing while coding?
Does anyone currently write GAS scripts, regularly using global vars. I'd be interested to hear how it all works? What the cons are, any limitations, or advantages.
EDIT BELOW THIS LINE
Just wanted to add, 95% of the things I've been doing have been confined to Google Sheets, with a lil gmail scripting. So that's my scope so far. Thought it best to mention, as I don't really have the implications for scripts for other Google products in mind.