Javascript에서 객체를 복사하는 방법은 다음과 같다.

 

const cloneObj = obj => JSON.parse(JSON.stringify(obj));
fileList = cloneObj(begFileList);
// 객체를 복사해서 변경해도 기존에 원본 객체는 바뀌지 않음

cloneObj에 obj를 복사한 것이다.

+ Recent posts