这里有一个菜鸟问题:看到一个 jQuery 代码是这样写的:
var PRINCIPAL = {};
PRINCIPAL.Function = function($element) {
var self = this;
/*more vars*/
this.init = function() {
self.initialFunction();
};
this.initialFunction = function() {
/*code here*/
};
this.secondOne = function() {
/*code here*/
};
this.init();
};
/*associative array below??*/
PRINCIPAL.array = {
CONFIGURATION: 10,
CONFIGURATION2: 200,
init: function($element) {
/*code here*/
},
firstFunction: function() {
/*code here*/
},
secondOne: function() {
/*code here*/
},
thirdOne: function() {
/*code here*/
}
};
/*and at the end it stars all functions inside the blocks*/
$(function() {
PRINCIPAL.array.init($('#element'));
});
好的,现在:上面有很多数组(?),还有一些其他的函数,所有的代码都被分成了块。我不太明白,这是一种编程风格还是什么?