javascript基础学习一:类

function Shape()
{
	var init = function(){
	
	} //模拟构造函数

	init();
	this.x = 1; //公有属性
	this.y = 2;
	this.draw = function(){
		console.log( this.x + this.y);		
	}; //公有方法
}

var ashape = new Shape();
console.log(ashape.x);
ashape.draw();

 类属性\方法的定义:

Shape.count = 10

Shape.staticMethod = function(){}

posted @ 2013-05-16 13:56  践道者  阅读(157)  评论(0编辑  收藏  举报