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

 

posted @ 2016-09-01 11:24  甜菜波波  阅读(2094)  评论(0编辑  收藏  举报