Created
March 5, 2013 03:51
-
-
Save katapad/5087870 to your computer and use it in GitHub Desktop.
Objectをcloneする方法。 prototypeにつっこんでnewとか、jQueryのextendでやるとかあるけど、これが一番シンプルで確実。
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 JSON.parse(JSON.stringify(obj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
コピーできるのはJSONのみ。クラスとかはcloneできない