extjsソース分析-001(Ext.appy)



/**
 * Copies all the properties of config to obj.
 * @param {Object}      
 * @param {Object}       --       
 * @param {Object}       --       
 * @return {Object} returns obj          
 * @member Ext apply
 */

Ext.apply = function(o, c, defaults){   
    // no "this" reference for friendly out of scope calls   
    if(defaults){   
        Ext.apply(o, defaults);   
    }   
    if(o && c && typeof c == 'object'){   
        for(var p in c){   
            o[p] = c[p];   
        }   
    }   
    return o;   
}; 
//     : c   defaults     o,    o  
//    :
var o = {};
var c = {name:'tom',showName:function(){alert(name);}};
var d = {age:23};
Ext.apply(o,c,d);