JavaScript Alternate definition


The Object.freeze() method is available since version 5.1. For older versions, you can use the following code (note that it also works in versions 5.1 and later):

var ColorsEnum = {
    WHITE: 0,
    GRAY: 1,
    BLACK: 2
// Define a variable with a value from the enum
var currentColor = ColorsEnum.GRAY;