Object.extend = function(destination, source){ for (var property in source) { destination[property] = source[property]; } return destination; } /*字符串*/ var string = new String("hello"); var string1 = string; var string2 = string; string1 = string1+" world!"; console.log(string+"|"+string1+"|"+string2); /*数组*/ var arr = [2012,11,12] var arr1 = arr.slice(0); var arr2 = arr.slice(0); arr2.push("4"); console.log(arr+"|"+arr1+"|"+arr2); /*对象*/ var obj = {name:"shao"}; var obj1 = Object.extend({},obj); var obj2 = Object.extend({},obj); obj1.name = "liang"; console.log(obj.name+"|"+obj1.name+"|"+obj2.name);