文章分类 -  JavaScript

摘要://第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 = function( r ) { return this.PI * 阅读全文
posted @ 2011-12-03 08:24 Alex~ 阅读(135) 评论(0) 推荐(0)