I'm working with Google Appscript, and after finally understanding the difference between the V8 runtime, the equivalent of standard library and the Web APIs, I think I developing an ok mental model for what running javascript in appscrpt involves.
However, I'm now looking for a way to feature detect when I am running inside the Google Appscript environment - and it's not obvious to me what the idiomatic way of doing so is.
For example, I know I can check if I'm in a Nodejs environment like so, as outlined in another SO answer around feature detection:
(typeof process !== 'undefined') &&
(typeof process.versions.node !== 'undefined')
And I know there there various Services and Global objects that Google Appscript makes available.
So, one way could be to check against a list of Services listed in the Google Appscript docs as available when running scripts, like Logger
, Menu
, Ui
. But I can see some of these being general enough to collide with common variable names you might see in javascript anyway.
Is there an 'blessed' set of objects to check for, or an idiomatic way to check if you're running in AppScript?
It seemed worth asking before I try feature detecting something from the list above, and finding out that hard way that there's a better way.