Enum

The Enum function is used to produce an Enum(eration) object.

An Enum object has a member that contains the string value of the members name. For example, the following returns an object with the member 'UNKNOWN' that points to the string "UNKNOWN".

var enum = new Enum( ["UNKNOWN"] )

is equivalent to:

enum         = {}
enum.UNKNOWN = "UNKNOWN"
function Enum( values )
{
    var e = {}
    var n = values.length;

    for ( var i=0; i < n; i++ )
    {
        var name = values[i]

        e[name] = name;
    }

    return e;
}