既然是用function来模拟类,所以编写代码创建类的关键字还是function。我们创建一个座标点类。
function Point() {this.X = 0;
this.Y = 0;
};
var zeroPoint = new Point();
alert("当前座标值( X:" + zeroPoint.X + " , Y:" + zeroPoint.Y + " )");既然是用function来模拟类,所以编写代码创建类的关键字还是function。我们创建一个座标点类。
function Point() {this.X = 0;
this.Y = 0;
};
var zeroPoint = new Point();
alert("当前座标值( X:" + zeroPoint.X + " , Y:" + zeroPoint.Y + " )");