/***定义类***/
var Class = function(){
var _self = this;//把本身引用负值到一变量上
var _Field = "Test Field"; //私有字段
var privateMethod = function(){ //私有方法
alert(_self.Property); //调用属性
}
this.Property = "Test Property"; //公有属性
this.Method = function(){ //公有方法
alert(_Field); //调用私用字段
privateMethod(); //调用私用方法
}
}
/***定义类***/
var Class = function(){
var _self = this;//把本身引用负值到一变量上
var _Field = "Test Field"; //私有字段
var privateMethod = function(){ //私有方法
alert(_self.Property); //调用属性
}
this.Property = "Test Property"; //公有属性
this.Method = function(){ //公有方法
alert(_Field); //调用私用字段
privateMethod(); //调用私用方法
}
/***析构函数***/
var init = function(){
privateMethod();
}
init();
}
var c = new Class(); c.Method(); //使用方法
function Shape()
{
var x=1;
var y=2;
}
function Shape()
{
this.x=1;
this.y=2;
}
function Shape()
{
var x=0;
var y=1;
this.draw=function()
{
//print;
};
}
function Shape()
{
var x=0;
var y=1;
var draw=function()
{
//print;
};
}
function Shape()
{
var init = function()
{
//构造函数代码
};
init();
}
function Shape(ax,ay)
{
var x=0;
var y=0;
var init = function()
{
//构造函数
x=ax;
y=ay;
};
init();
}
function Shape(ax,ay)
{
var x=0;
var y=0;
var init = function()
{
//构造函数
x=ax;
y=ay;
};
init();
}
Shape.count=0;//定义一个静态属性count,这个属性是属于类的,不是属于对象的。
Shape.staticMethod=function(){};//定义一个静态的方法
alert ( aShape.count ); aShape.staticMethod();
function Shape(ax,ay)
{
var x=0;
var y=0;
this.gx=0;
this.gy=0;
var init = function()
{
x=ax;//访问私有属性,直接写变量名即可
y=ay;
this.gx=ax;//访问公有属性,需要在变量名前加上this.
this.gy=ay;
};
init();
}
function Shape(ax,ay)
{
var _this=this; //把this保存下来,以后用_this代替this,这样就不会被this弄晕了
var x=0;
var y=0;
_this.gx=0;
_this.gy=0;
var init = function()
{
x=ax;//访问私有属性,直接写变量名即可
y=ay;
_this.gx=ax;//访问公有属性,需要在变量名前加上this.
_this.gy=ay;
};
init();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有