Shallow vs. Deep Copying Objects

Shallow Copying Objects:

  • Will duplicate the top-level properties but nested object is shared between original and the copy
  • Pitfall: 계속 순환 참조
  • will affect ‘array inside array’ if it modifies since it is shallow copying objects

Deep Copying Objects:

  • Pitafall: if you put user’s method, it will cause an error.
  • 서버 통신에서는 딮카피가 맞음
  • 자바스크립트는 객체나 배열이 아니라 그냥 글자임