发布于 2016-12-22 13:14:14 | 172 次阅读 | 评论: 0 | 来源: 网友投递
这里有新鲜出炉的Javascript教程,程序狗速度看过来!
JavaScript客户端脚本语言
Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。
第一种模式:工厂方式
var lev=function(){
return "phperz";
};
function Parent(){
var Child = new Object();
Child.name="脚本";
Child.age="4";
Child.lev=lev;
return Child;
};
var x = Parent();
alert(x.name);
alert(x.lev());
var lev=function(){
return "phperz";
};
function Parent(){
this.name="脚本";
this.age="30";
this.lev=lev;
};
var x =new Parent();
alert(x.name);
alert(x.lev());
var lev=function(){
return "phperz";
};
function Parent(){
};
Parent.prototype.name="李小龙";
Parent.prototype.age="30";
Parent.prototype.lev=lev;
var x =new Parent();
alert(x.name);
alert(x.lev());
function Parent(){
this.name="脚本";
this.age=4;
};
Parent.prototype.lev=function(){
return this.name;
};;
var x =new Parent();
alert(x.lev());
function Parent(){
this.name="脚本";
this.age=4;
if(typeof Parent._lev=="undefined"){
Parent.prototype.lev=function(){
return this.name;
}
Parent._lev=true;
}
};
var x =new Parent();
alert(x.lev());
if(typeof Parent._lev=="undefined"){
Parent._lev=true;}