var obj = { a: "aaaaaa" }; var obj1 = { b: "bbbbbb" }; Object.extend = function (destination, source) { for (property in source) { destination[property] = source[property]; } return destination; } Object.extend(obj, obj1); alert(JSON.stringify(obj)); //结果为{"a":"aaaaaa","b":"bbbbbb"}
原文:http://www.cnblogs.com/tiancai/p/5829094.html