JavaScript类定义的方式哪种比较好?

来源:百度知道 编辑:UC知道 时间:2024/06/23 04:04:33
如题...
http://www.javaeye.com/topic/161837
这里说有5种
http://topic.csdn.net/t/20041208/16/3626957.html
这里一种
平时只接触C#和VBSCRIPT,没想到Javascript类定义这么麻烦...OTZ

我喜欢使用构造方式,其实哪种都是一样的。

定义函数的形式更符合逻辑...

function Car(){
this.run = function(){
alert("Car run!");
}
this.stop = function(){
alert("Car stop!");
}
}

var c = new Car();

c.run();
c.stop();

显然,我觉得这种方法更舒服..

不麻烦的...因为JS没有CLASS的概念嘛~~

所有元素都是对象~~~function包裹function...

我用的就是你发的CSDN里的那种方法,调用非常方便

都一样