Skip to content

Instantly share code, notes, and snippets.

@Starefossen
Created December 16, 2012 16:06
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 Starefossen/4308928 to your computer and use it in GitHub Desktop.
Save Starefossen/4308928 to your computer and use it in GitHub Desktop.
Makes it possible to extend object in the following way: myObject.extend otherObject
# Extend Object Prototype
Object::extend = (obj) ->
org = this
Object.keys(obj).forEach (key) ->
prop = Object.getOwnPropertyDescriptor obj, key
Object.defineProperty org, key, prop
this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment