Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.

Enum_API

rdking edited this page Dec 6, 2014 · 2 revisions

#Enum.js

Provides a factory for creating well defined enumerated types.

###Constructor

new Enum(<default>, [<element1>, <element2>, ...]);
new Enum(<default>, {<element1>: <value1>, <element2>: <value2>, ...});
  • default: String name of the element that is the default value for a newly created Enum instance.
  • elementN: String name of the element at position N.
  • valueN: A primitive or object to be considered the value of the corresponding element.

If array notation is used when specifying the Enum type's values, then the value of the element is its index in the array. While all element names must be unique, there is no requirement that all values also be unique.

###Enum Types

Using the Enum constructor creates a new Enum type. This new type has attached to it a property for each of the element names specified in the constructor, the value of which is a corresponding instance of that same type.

#####Properties

  • name: String name of the element.
  • value: Associated value of the element.
Clone this wiki locally