Created
April 10, 2012 14:02
-
-
Save h2rd/2351588 to your computer and use it in GitHub Desktop.
Clone object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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