摘要: //定义Circle类,拥有成员变量r,常量PI和计算面积的成员函数area()//第1种写法 function Circle(r) { this.r = r;}Circle.PI = 3.14159;Circle.prototype.area = function () { return Circle.PI * this.r * this.r;}var c = new Circle(1.0);alert(c.area());//第2种写法 var Circle = function() { var obj = new Object(); obj.PI = 3.... 阅读全文
posted @ 2013-03-07 16:30 VipSoft 阅读(257) 评论(0) 推荐(0)