為什么這個(gè)深拷貝無法得到函數(shù)func: function(){return 1}是不是函數(shù)無法復(fù)制?fucntion deepClone(source) { var targetObj = {}; for(var keys in source) { if(source.hasOwnProperty(keys)) { if(source[keys] && typeof source[keys] === 'object') { targetObj[keys] = deepClone(source[keys]); }else{ targetObj[keys] = source[keys]; } } } return targetObj;}var o1 = { arr: 1, obj: { key: 'value' }, func: function(){ return 1; }}var o3 = deepClone(o1);console.log(JSON.stringify(o3));
關(guān)于深拷貝問題
繁華開滿天機(jī)
2019-03-07 18:15:13