Created
May 25, 2017 18:12
-
-
Save gustavomdsantos/8066d261c310cfe0c86d302a9716d86c to your computer and use it in GitHub Desktop.
Não existem enums em CoffeeScript/JavaScript (é inútil um conceito desses em linguagens dinâmicas), mas é possível fazer um artifício para se ter um objeto cujos valores de atributos são constantes (imutáveis). Fonte: https://stackoverflow.com/a/32450001
This file contains hidden or 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
| Colors = Object.freeze | |
| RED: 'red' | |
| GREEN: 'green' | |
| BLUE: 'blue' | |
| console.log Colors.RED | |
| Colors.RED = 'black' # it won't change (constant value) | |
| console.log Colors.RED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment