//返回新对象,双方互不影响 function clone(obj){ //alert('clone'); if(typeof(obj) != 'object') return obj; if(obj == null) return obj; //因为typeof(null) == object所以要加上这步 var newObj = {}; for(var i in obj){ newObj[i] = clone(obj[i]); //alert('obj['+i+'] '+obj[i]); } return newObj; } function clone2(obj){ //alert('clone2'); function F(){} F.prototype = obj; return new F(); }