Using constants as indices for JavaScript associative arrays
In ECMAScript 6 you can use computed values for object keys: var CONSTANT_A = 0, CONSTANT_B = 1 var state_machine = { [CONSTANT_A]: function () { return ‘a’ }, [CONSTANT_B]: function () { return ‘b’ } }; console.log(state_machine) This does not work in Internet Explorer 11 nor in Safari browsers: https://kangax.github.io/compat-table/es6/#test-object_literal_extensions_computed_properties