<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ExtJs原理</title>
</head>
<body>
<script>
APPLE = {};//声明全局变量
/**
* 复制属性的方法,复制config对象的所有属性到obj(第一个参数为obj,第二个参数为config,
* 第三个为默认对象,如果该参数存在,obj将会得到那些defaults有而config没有的属性)
*/
APPLE.apply = function(o, c, defaults){
if(defaults){
APPLE.apply(o, defaults);
}
if(o && c && typeof c == 'object'){
for(var p in c){
o[p] = c[p];
}
}
return o;
};
(function(){//声明匿名函数并调用为全局变量赋值
/**
* 此方法等同于
* APPLE = {
* test : function(){
* alert('test');
* }
* };
*/
APPLE.apply(APPLE, {
test : function(){
alert('test');
}
});
})();
APPLE.test();//调用赋值后的方法
</script>
</body>
</html>