Skip to content

Instantly share code, notes, and snippets.

@eluck
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eluck/74a5a8f8262d85497ab6 to your computer and use it in GitHub Desktop.
Save eluck/74a5a8f8262d85497ab6 to your computer and use it in GitHub Desktop.
Function::constants = (obj) ->
for key, value of obj
Object.defineProperty @prototype, key, value: value, writable: false, enumerable: true
class Person
@constants
FullName: 'Leroy Jenkins'
p = new Person
console.log(p.FullName)
p.FullName = 'Leroy Monkey'
console.log(p.FullName)
@eluck
Copy link
Author

eluck commented Oct 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment