網(wǎng)站公告:
咨詢(xún)熱線(xiàn):0755-23316625

產(chǎn)品信息

熱門(mén)動(dòng)態(tài)

    暫無(wú)信息

推薦動(dòng)態(tài)

    暫無(wú)信息
var obj = {a:10}; function copy(obj){ var newobj = {}; for ( var attr in obj) { newobj[attr] = obj[attr]; } return newobj; } var obj2 = copy(obj); obj2.a = 20; alert(obj.a); //10 var obj = {a:{b:10}}; function copy(obj){ var newobj = {}; for ( var attr in obj) { newobj[attr] = obj[attr]; } return newobj; } var obj2 = copy(obj); obj2.a.b = 20; alert(obj.a.b); //20 var obj = {a:{b:10}}; function deepCopy(obj){ if(typeof obj != 'object'){ return obj; } var newobj = {}; for ( var attr in obj) { newobj[attr] = deepCopy(obj[attr]); } return newobj; } var obj2 = deepCopy(obj); obj2.a.b = 20; alert(obj.a.b); //10