(info) This AI is still in early stages of development.

Define.has()

Check for presence of a global property...

 

Syntax

var result = Define.has(name);

Parameters

ParameterTypeMandatoryNotesAPI Version
nameString(tick)The name of the global property to test.1.0

Return values

ValueTypeNotesAPI Version
trueBoolean

The named property exists.

Specifically it's state is either Define.NATIVE, Define.REPLACED or Define.ADDED.

1.0
falseBoolean

The named property does not exist or has been removed.

Specifically it's sate is either Define.MISSING or Define.REMOVED.

1.0

Example

Define scavengerPlayer if it doesn't exist...
if (!Define.has("scavengerPlayer")) { // WZ 3.1 branch
	Define(
		"scavengerPlayer",
		(scavengers) ? Math.max(7, maxPlayers) : -1
	);
}
Availability STABLE

Requires:

Contents

Jump to:

Define API

Topics:

  • Define() — Add, remove or redefine a property on the global scope, overriding any native property of the same name on the global object...
    • Define.has() — Check for presence of a global property...
    • Define.RESERVED — A reserved keyword (a native that cannot be changed)...
    • Define.stateOf() — Check state of a specific global property...
    • Define.hasNative() — Check for presence of a native global property...
    • Define.REMOVED — Indicates a native global was removed...
    • Define.MISSING — Indicates a global is not present (missing).
    • Define.NATIVE — Indicates a global was defined prior to including the Define API.
    • Define.REPLACED — Indicates a global was replaced by a script using the Define API.
    • Define.ADDED — Indicates a global was added by a script using the Define API.
  • Define API Diagnostics — Diagnostic routines for Define API...
  • Define Scripts — A library of ready made scripts for the Define API...

Â