(function WJ( ){
var CH=function( ){
return new CH.prototype.init( );
};
CH.prototype={
init:function( ){
return this;
},
length:10
};
CH.prototype.init.prototype=CH.prototype;
window.CH=CH( );
})( )
alert(CH.length);
大家用什么方式初始化代码,设置命名空间,组合自己代码或者组件的。。。
------解决方案--------------------
我的方法与你的不同, --可能没你的好!
但是,即然你都这么说了, (没人愿意分享?)
那我就贴出我的代码吧!(其实我是不敢贴出的)
我写贯了C# 的方式。js 也当C# 的来写
- JScript code
// 在外部 接口 函数 // this.animal //使用说明 // this.sayHello //使用说明 // var Animal =function (AN) { this.Name = (AN)?AN:null;; //这里是构造 this.animal=function(AN){ this.Name=(AN)?AN:null; }; this.sayHello = function(){}; //... };