$.extend 合并对象(处理可传入0个或多个参数)

function test(options){
            $.extend({ },this.Default,options);
    
            var v = this.Default || options;

            alert(v.name);//传入打印'嘻嘻嘻嘻',不传入打印'呵呵呵'
        }   
        test.prototype.Default = {
         name:'呵呵呵'
        };
        new test({name:'嘻嘻嘻嘻'});
     //js可传入对象,也可不传入,不传入时使用默认
 
 
function test1(options){
         var defaults = { name: "foo" };
            $.extend({ },defaults,options);
    
            var v = defaults || options;

            alert(v.name);//传入打印'嘻嘻嘻嘻',不传入打印'呵呵呵'
        }   
        new test1({name:'ssss'});
posted @ 2019-01-15 17:20  雨夜稻草  阅读(555)  评论(0编辑  收藏  举报