Skip to content

Instantly share code, notes, and snippets.

@donnut
Last active August 29, 2015 14:07
Show Gist options
  • Save donnut/d9d9be2361797740d171 to your computer and use it in GitHub Desktop.
Save donnut/d9d9be2361797740d171 to your computer and use it in GitHub Desktop.
deep copy prototype
Prototypical description of a deep copy method
deepCopy:: a -> b
copyDate:: Date -> Date
a == Number ? s = a:
a == String ? b = a:
a == Boolean ? b = a:
a == Function ? b = a: // remains by reference
a == Date ? b = copyDate a:
a == Object ? b = deepCopy a.keys[]:
a == Array ? (a:as) => b = deepCopy a, deepCopy as
- circular references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment