Skip to content

Instantly share code, notes, and snippets.

@jacobrask
Created November 29, 2011 12:31
Show Gist options
  • Select an option

  • Save jacobrask/1404650 to your computer and use it in GitHub Desktop.

Select an option

Save jacobrask/1404650 to your computer and use it in GitHub Desktop.
Object.extend suggestion in CoffeeScript
unless typeof Object.extend is 'function'
Object.defineProperty Object, 'extend',
value: (orig, ext) ->
props = {}
for name in Object.getOwnPropertyNames(ext) when name not in orig
props[name] = Object.getOwnPropertyDescriptor ext, name
Object.create orig, props
configurable: true
writable: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment