zhenglu

导航

2013年7月23日 #

JS 中面向对象的5种写法

摘要: //第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.14159; obj.area = functio... 阅读全文

posted @ 2013-07-23 11:29 zhenglu 阅读(229) 评论(0) 推荐(0)