Add, remove or redefine a property on the global scope, overriding any native property of the same name on the global object...
Syntax
Define(); // returns an object describing all defines
Define(name); // returns status associated with name
Define(name, value); // add, remove or redefine a global
Parameters
Parameter
Type
Mandatory
Notes
API Version
name
String
The name of the define to check / add / remove / replace.
If adding, removing or replacing a define, the value parameter must be also specified...
1.0
value
Function
Null
Undefined
Boolean
String
Number
If specified, the name parameter must also be specified.
A new global const called name will be defined (in the global scope) with a value of value, overriding any property of the same name on the global object:
A value of null or undefined will set the value of the global const to undefined, effectively removing the property of the same name on the global object. A define state of Define.REMOVED will be attributed to name.
Other values denote the addition or override of of the named property on the global object, with states of Define.ADDED or Define.REPLACED being attributed to their name.
Note that generic objects and arrays are not currently supported. These can be handled in future versions if there are sufficient valid feature requests.
1.0
Return values
Different return values will be generated depending on the parameters supplied:
No parameters – an object describing all current defines (keys) and their status (values)
Name parameter – a constant describing the state of the define
Name and value – define a new value for the named property
Value
Type
Notes
API Version
<error>
Error
An error occurred, most likely:
Invalid parameters
Trying to define a reserved global property (eg. Math or me)
Trying to define something that's already defined
1.0
<obj>
Object
If no parameters are specified, an object describing all current defines will be returned.
The enumerable named own properties of the object are the names of things that have been defined, and their values are the statuses of those defines.
Status values can be:
Define.ADDED – the global property was added by Define()
Define.NATIVE – the global property existed prior to including Define API
Define.REPLACED – the global property has been replaced by Define()
Define.REMOVED – the global property has been removed by Define()
1.0
<state>
Constant
If both a name and value were specified, this will be the status of the named property after being defined. Status values can be those listed above.
If only the name parameter was specified, this will be the status of the named property. Status values can be those listed above and, in addition, Define.MISSING which indicates the global property does not exist.