首页 > 代码库 > js extend的实现

js extend的实现

   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"}

 

js extend的实现