Created
September 16, 2013 02:01
-
-
Save matthewhudson/6575957 to your computer and use it in GitHub Desktop.
Simple clone() implemented in coffee
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 = (obj) -> | |
return obj if not obj? or typeof (obj) isnt "object" | |
tmp = obj.constructor() | |
for key of obj | |
tmp[key] = clone(obj[key]) | |
tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment