Skip to content

Instantly share code, notes, and snippets.

@gustavomdsantos
Created May 25, 2017 18:12
Show Gist options
  • Select an option

  • Save gustavomdsantos/8066d261c310cfe0c86d302a9716d86c to your computer and use it in GitHub Desktop.

Select an option

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
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