Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Excerpt

An API for defining, redefining and un-defining global functions and constants.

 

adding, removing or replacing properties on the global object / scope.

 

Overview

The primary purpose of the Define API is to alter the native Javascript API provided by Warzone 2100.

The JS API defines all it's constants, globals and functions as read-only, non-configurable properties on the global object. As such, they can only be altered by variables and constants in the global scope. Unfortunately, if you try defining a variable or constant in the global scope, and there is an immutable property of the same name on the global object, an error will be thrown – Javascript detects that you are doing something potentially stupid and steps in to block the action.

The Define API wraps some JS trickery in to a robust and reliable API which makes it trivially easy to work around these issues. Furthermore, you don't have to script your defines in the context of the global scope - you can put them in closures to keep them neatly packaged and avoid spamming the global object and scope with countless internal variables.

 

Div
classbox
Availability
Status
colour
Green
Yellow
title
Stable
Beta

Requires:

Div
classbox

Define API

Topics:

Child pages (Children Display)
alltrue
depthall
pageDefine API
excerpttrue