Alternate definition

suggest change

Object.freeze() has been available since ECMAScript 5. Where it is unavailable, a plain object can stand in for an enum. Unlike Object.freeze(), this object can still be changed:

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents