【记录】这样在网页里构造JS 更加容易理解
代码Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
var aa=Class.create();
aa.prototype={
initialize:function(options){
this.SetOptions(options);
},
SetOptions: function(options) {
this.options = {//默认值
xxx: 0,//最小值
};
Object.extend(this.options, options || {});
},
show:function(){
alert(this.options.xxx)
}
}
var cc=new aa({xxx:100})
cc.show();
代码Object.extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
var bb=function(o){
this.options={xxx:0};
Object.extend(this.options, o || {});
}
bb.prototype={
show:function(){
alert(this.options.xxx)
}
}
var dd=new bb({xxx:100})
dd.show()