網(wǎng)站公告:
咨詢熱線:0755-23316625

產(chǎn)品信息

推薦

    暫無信息

熱門

    暫無信息
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