Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Indicates a global was replaced by a script using the Define API. |
Notes
A define with state Define.REPLACED was originally native, but has since been replaced using Define().
Replaced defines are immutable.
If the define is a function, the native function will be available via a 'native
' property on that function (see first example below).
Note: If the define wasn't originally native, the new define would have a state of Define.ADDED.
Examples
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// always use strict equality checks
if (Define.stateOf("chat") === Define.REPLACED) {
// native chat function existed, but was replaced by a script
chat(me, "This is using the replacement chat function");
// the native chat() function is still available via
chat.native(me, "This is using the native chat function");
} |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// when using switch, order of cases is vitally important
switch (Define.stateOf("chat")) {
case Define.MISSING : return "chat() is missing";
case Define.REMOVED : return "chat() was removed by script";
case Define.ADDED : return "chat() was added by script";
case Define.REPLACED: return "chat() was overridden by script";
case Define.NATIVE : return "chat() function is native";
default: return "Status of chat() is unknown";
} |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Define APITopics:
|