Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created April 10, 2012 14:02
Show Gist options
  • Save h2rd/2351588 to your computer and use it in GitHub Desktop.
Save h2rd/2351588 to your computer and use it in GitHub Desktop.
Clone object
clone = (object) ->
if not object? or typeof object isnt 'object'
return object
instance = object.constructor()
for key of object
instance[key] = clone object[key]
return instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment