Upgrade to Pro — share decks privately, control downloads, hide ads and more …

objectのcloneを行う/How to clone of the object in js

objectのcloneを行う/How to clone of the object in js

誰もが一度は踏んでしまう、objectをコピーする際の参照渡しの罠についてと、安全なdeep cloneの方法について。

52ecfbc87e5145ed5cd8cd81de9cffa8?s=128

Kazunori-Kimura

October 15, 2018
Tweet

Transcript

  1. +BWB4DSJQU5JQT PCKFDUͷDMPOFΛߦ͏  ໦ଜݑن

  2. PCKFDUͷ᠘ +BWB4DSJQUʹ͸PCKFDUʹDMPOFϝιου͕ͳ͍ PCKFDUͷ୅ೖ͸ࢀর౉͠  

  3. ҙਤͤͣݩPCKFDUΛมߋͯ͠ ͠·͏͜ͱ͕  

  4. 0CKFDUBTTJHOϝιουΛ࢖ ༻ͨ͠DMPOF  

  5. 0CKFDUBTTJHOʹ͍ͭͯ  

  6. 0CKFDUBTTJHOʹΑΔDMPOF ͷ᠘  

  7. PCKFDUͷEFFQDPQZΛ࣮֬ ʹ࡞੒͢Δʹ͸  

  8. ·ͱΊ PCKFDUͷ୅ೖ͸ࢀর౉͠ ˠ ҙਤͤͣݩPCKFDUΛมߋͯ͠͠·͏͜ͱ͕͋Δ ˠ +BWB4DSJQUͰ͸PCKFDUΛଟ༻͢ΔͷͰɺ͜Ε͕ݪ ҼͷόάΛ࡞Γ͕ͪ EFFQDMPOFʹ͸ A+40/QBSTF +40/TUSJOHJGZ

    PCK A͕͓͢͢Ί