Last active
May 31, 2016 15:10
-
-
Save MhdSyrwan/dea89f37f5057d6d079e98c697ffa3cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const POSITION = (function() { | |
var inner = {}; | |
Object.defineProperty(inner, 'left', { | |
writable: false, | |
value: 1 | |
}) | |
Object.defineProperty(inner, 'right', { | |
writable: false, | |
value: 2 | |
}) | |
Object.defineProperty(inner, 'middle', { | |
writable: false, | |
value: 3 | |
}) | |
return inner; | |
})(); | |
console.log(POSITION.left); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ENUM(values) { | |
var inner = {}; | |
for(var i=0; i < values.length; i++) { | |
Object.defineProperty(inner, values[i], { | |
writable: false, | |
value: i + 1 | |
}) | |
} | |
return inner; | |
} | |
POSITION = ENUM(['left', 'right', 'middle']); | |
console.log(POSITION.left); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment