Reputation: 300
I am trying to learn about the ScriptProperties object in GAS.
I tried setting a property to a value of null, and I get an error.
I can understand if like JavaScript, setting a value of null undefines that property.
But why are you disallowing this value? It seems reasonable (to me) to allow a script to undefine a script (or user) property.
Another question about ScriptProperties (and I assume the same holds for UserProperties), Why when I display the value of an undefined property it displays as "undefined", but when I try to test for the value "undefined" (without quotes) it does not match?
It seems, that if you are going to introduce a new special attribute value of "undefined", it should be consistent through out the system. If by "undefined" you mean null, well then why not display it with the word "null"?
I am just trying to learn about this new environment. All help is appreciated. Thanks for your support.
Upvotes: 0
Views: 287
Reputation: 12671
There is an open feature request to add support for removing properties, which you can star for updates.
The value "undefined" is not a string but rather a special value built in to JavaScript. You can refer to it like "null":
if (foo == undefined) { ...
More information is available on the w3schools page.
Upvotes: 1