varcopyObjectDeep=function(target){varresult={};if(typeoftarget==='object'&&target!==null){for(varpropintarget){result[prop]=copyObjectDeep(target[prop]);}}else{result=target;}returnresult;};varuser={name:'Jason',urls:{portfolio:'http://github.com/abc',blog:'http://blog.com',facebook:'http://facebook.com/abc',},};varuser2=copyObjectDeep(user);user.name='Mraz';user2.name='Bbo';user.urls.blog='google';user2.urls.facebook='meta';console.log(user);console.log(user2);// JSON 활용 깊은 복사varcopyObjectViaJSON=function(target){returnJSON.parse(JSON.stringify(target));};varobj={a:1,b:{c:null,d:[1,2],func1:function(){console.log(3);},},func2:function(){console.log(4);},};varobj2=copyObjectViaJSON(obj);console.log(obj);console.log(obj2);