继续学习javascript delegate object
<body onload="gg();">
// JScript 文件
object =new Object();
object.a="33";
object["c"]="44";
object.GetTotal=function(){alert(this.a+this.b);};
function gg()//在这里实现调用
{
object.GetTotal();
myAnimal.study();
alert(myAnimal.sex);
var fristStudent = new student("alex");//类的实例化
fristStudent.play();
var secondStudent = new studentprototype("mo");
alert(secondStudent.age);
(myAnimal.sex).adverse();
}
//---------------------------------
var myAnimal={
name:"alex",
sex:"male",
age:"20",
study:function(){alert("good");},
play:function() {alert("basketball");}
}
//-----------------------------------------
function student(name)
{
this.name=name;
this.sex ="male";
this.age="20";
this.study=function(){alert("good");},
this.play =function() {alert("basketball");}
}
//------------------------------------------
function studentprototype(name)
{
this.name = name;
}
studentprototype.prototype.sex="male";
studentprototype.prototype.age="20";
studentprototype.prototype.study=function(){alert("good");};
studentprototype.prototype.play=function(){alert("basketball");};
//------------------------------------------------
String.prototype.reverse = function(){
var out = '';
for(var i=this.length-1; i>=0; i--)
{
out+=this.substr(i, 1);
}
return out;
}
alert('asdf'.reverse());
String.prototype.adverse=function(){
re(this);
};
function re(obj)
{
var out="";
for(var i=obj.length-1;i>=0;i--)
{
out += obj.substr(i,1);
}
alert(out);
}
//--------------------------------------------------------------------------------

浙公网安备 33010602011771号