资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

李站javascript,李站丰

谁教的Javascript 好学

你看李站的 《悟透javascript》 里边是卡通形式的,但是特别的好,能够教会你对象字面量,面向对象,还有写代码时候的技巧(还有ajax哦)。最后还有一个完整的教你怎么做五子棋的程序。

创新互联建站专注于企业营销型网站建设、网站重做改版、连城网站定制设计、自适应品牌网站建设、成都h5网站建设电子商务商城网站建设、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为连城等各大城市提供网站开发制作服务。

里边用的东西我觉得很形象,很适合学习的。

然后还有一本是 《javascript精粹》这个主要讲的是js里边的技巧。建议看完上一本后看这个。

《javascript权威指南》 是一本讲里边方法的书,如果你不了解js里边的哪些方法的话,可以看这个。

《javascript程序设计》我觉得是一本特牛的,里边讲了面向对象里所有的名词。建议你看完上边的,学这个,如果这个学完,你就是很牛的了

希望这些对你有帮助。

追击者中的李站长演员

剧名:《追击者》

角色:李如宾

演员:罗嘉良

简介:军统保定站站长,阅人无数,是一个不好对付的上司。他深谙官场之道,时而精明凌厉,时而假装糊涂,让大家琢磨不透。他的心思缜密,受过很好的教育,说话语速较慢,一板一眼,对自己的服饰发型非常讲究。外表看上去十分有涵养,但其实心细如发,疑心极重,不相信任何一个人。

javascript问题,请帮我看看下面的语句有什么错误?

悟透javascript的总结和心得及简单的案例:

编程世界里的两种元素:数据和代码;

Javascript中的简单数据:undefined,null,boolean,number,string;全都是小写的;

Javascript中的内置函数:Number,String,Object,Function;javascript区分大小写;

Typeof返回返回表明的类型;

完全有数组组成的字符串与该字符串表示的的值是相等的;比如”123”=123;注意:”0123”==123的值是false;因为javascript将0开头的整数常量以8进制处理,所以”0123”是8进制,”123”是10进制;

Object就是对象的类,在javascript中不管是复杂的数据和代码,都可以组成object形式的对象;

script

type="text/javascript"

var

life={};

for(life.age=1;life.age3;life.age++){

switch(life.age){

case

1:

life.body="卵细胞";

life.say=function(){alert(this.age+this.body)};

break;

case

2:

life.tail="尾巴";

life.gill="腮";

life.body="蝌蚪";

life.say=function(){alert(this.age+this.body+this.tail+this.tail)};

break;

case

3:

delete

life.gill;

delete

life.tail;

life.legs="四条腿";

life.lung="肺";

life.body="青蛙";

life.say=function(){alert(this.age+this.body+this.legs+this.lung)};

break;

};

life.say();

}

/script

Javascript的内置函数;

函数的写法分为:定义式和变量式;

script

type=”text/javascript”

Var

myfun=function(){

Alert(“你好”);

};

Myfun();

Myfun=function(){

Alert(“yeah”);

};

Myfun();

/script

此为,变量式;第一次调用函数后,函数变量又被赋予了新的函数体,所以输出不同;

script

type=”text/javascript”

Function

myfun(){

Alert(“hello”);

};

Mufun();

Function

myfun(){

Alert(“huhu”);

};

Myfun();

/script

函数签名相同的函数;因为两个函数签名相同,所以后一个把前一个的内容输出覆盖了,所以只会输出对后一个的内容;

Javascript的作用域:

在javacript里的全局环境就是一个对象,这个对象是javascrit运行环境的跟,对于浏览器中的javascript来说,这个跟对象就是window对象,对于全局的

javascript语句来说,window对象就相当与当前的作用域;

Var

myname=”leadzen”;

就是定义了window作用域的一个变量myname;

Nyname=”leaden”;

定义了window对象的一个属性myname;

script

type="text/javascript"

var

youname="sunyuan";

myname="zh";

alert(myname+"like"+youname);//输出zh like

sunyuan;

change();

function

change(){

alert("you old name

is"+youname); //you old name is undefined;

alert("my name

is"+myname);//my name is zh;

var

youname="susu";

myname="kiki";

alert(myname+"like"+youname);//kiki like

susu;

};

alert(myname+"like"+youname);//kiki like

sunyuan

/script

了解caller属性的用法;

script

type="text/javascript"

function

whocallme(){

alert("my caller

is"+whocallme.caller);//输出自己的caller;

};

function

callera(){whocallme();};

function

callerb(){whocallme();};

alert(whocallme.caller);//输出null;

whocallme();//输出mycallme

is null;

callera();//输出mycallme

is function callera(){whocallme();};

callerb();//输出mycallme

is function callera(){whocallme();};

/script

如果函数的caller属性是null,表示函数没有被调用或者是被全局代码调用,函数的caller属性值实际是动态变化的,函数的初始caller值都是null,当调用一个函数时,如果代码已经运行在某个函数体内,javascript执行将会被caller属性设置为当前函数,在推出被调用的作用域时,被调用的caller属性又会被恢复为null值;

Javascript中只有object和function两种东西才又对象化能力;

script

type="text/javascript"

function

sing(){

alert(sing.author+":"+sing.poem);

};

sing.author="李白";

sing.poem="天使的翅膀是爱做的,孙媛的心是用关怀呵护的";

sing();

sing.author="李站";

sing.poem="能力不是一朝一夕就能变强的,需要时间,需要积累";

sing();

/script

Sing()函数定义后,又给sing()函数动态的增加author和poem属性;

对于对象:

script

type="text/javascript"

var

anobject={};//一个对象;

anobject.aproperty="property of

object";//对象的一个属性;

anobject.amethod=function(){alert("method of

object")};//对象的一个方法;

alert(anobject["aproperty"]);//可以将对象当数组以属性名作为下标来访问属性;

anobject["amethod"];//以对象当数组以方法名作为下标来调用方法;

for(var s in

anobject){//遍历对象的所有属性和方法进行迭代处理;

alert(s+"is

a"+typeof(anobject[s]));

}

/script

对于函数:

script

type="text/javascript"

var

anobject=function(){};//一个函数

anobject.aproperty="property of

object";//函数的一个属性;

anobject.amethod=function(){alert("method of

object")};//函数的一个方法;

alert(anobject["aproperty"]);//可以将函数当数组以属性名作为下标来访问属性;

anobject["amethod"];//以函数当数组以方法名作为下标来调用方法;

for(var s in

anobject){//遍历函数的所有属性和方法进行迭代处理;

alert(s+"is

a"+typeof(anobject[s]));

}

/script

Javascript中的this用法:

script

type="text/javascript"

function

whoami(){//定义一个函数;

alert("i am

"+this.name+"of"+typeof(this));

};

whoami();//this是根对象window,name属性为空,输出:i am of

object;

var

billgates={name:"bill gates"};

billgates.whoami=whoami;//将函数whoami作为billgates的方法;

billgates.whoami();//输出i

am billgates of object;

var

stevejobs={name:"steve jobs"};

stevejobs.whoami=whoami;

stevejobs.whoami();

whoami.call(billgates);

whoami.call(stevejobs);

whoami.whoami=whoami;

//将whoami设置为自身的方法;

whoami.name="whoami";//此时this是whoami自己;

whoami.whoami();

({name:"nobody",whoami:whoami}).whoami();//创建一个匿名对象并调用方法,输出:i

am nobody of object;

/script

Json数据 javascript

object natation javascript对象表示法

script

type="text/javascript"

var

person={

name:"sunyuanyuan",

product:"softname",

chairman:{name:"shagua",age:90},

employees:[{name:"huhu",age:89},{name:"asd",age:67}],

readme:function(){return

(this.name+"product"+this.product);}

}

alert(person.name);

alert(person.product);

alert(person.chairman.name);

alert(person.chairman.age);

alert(person.employees[0].name);

alert(person.employees[0].age);

alert(person.employees[1].name);

alert(person.employees[1].age);

alert(person.readme());

/script

注意:这里面的readme函数是有返回值的,就在弹出框俩面显示调用内容;

script

type="text/javascript"

var

person={

name:"sunyuanyuan",

product:"softname",

chairman:{name:"shagua",age:90},

employees:[{name:"huhu",age:89},{name:"asd",age:67}],

readme:function(){document.write

(this.name+"product"+this.product);}

}

alert(person.name);

alert(person.product);

alert(person.chairman.name);

alert(person.chairman.age);

alert(person.employees[0].name);

alert(person.employees[0].age);

alert(person.employees[1].name);

alert(person.employees[1].age);

alert(person.readme());

/script

注意:弹出框里面的东西是undefined;会在页面显示调用内容;

Javascript里面的构造对象:

在javascript里面可以用new操作符结合一个函数的形式来创建对象,

Function

myfun(){};

Var an=new

myfun();

Var an1=new

myfun();

等价于:

Function

myfun(){};

Var

an={};

Myfun.call(an);

Javascript里面的构造函数;

script

type="text/javascript"

function

person(name){//带参数的构造函数;

this.name=name;//定义并初始化name属性;

this.sayhello=function(){//定义对象方法sayhello();

alert("hello i am

"+this.name);

};

};

function

emp(name.salary){//在构造函数;

person.call(this.name);//调用父类构造函数;

this.salary=salary;//添加属性;

this.showm=function(){

alert(this.name+"$"+this.salary);//添加对象方法;

};

};

var aa=new

person("sunayun");//创建person类的aa对象;

var bb=new

showm("sinsi",1233);//创建showm类的bb对象;

aa.sayhello();//i am,

sunayun

bb.sayhello(); //i am

sinsi

bb.showm();//sinsi $

1233

alert(aa.constructor==person);//ture

alert(bb.constructor==emp);//true;

alert(aa.sayhello==bb.sayhello);//false

/script

Javascript中的原型(prototype)

script

type="text/javascript"

function

person(name){

this.name=name;

//设置对象属性,每个对象各自有一份属性数据;

};

person.prototype.sayhello=function(){//给person函数的prototype添加sayhello方法;

alert("hello i

am"+this.name);

}

var aa=new

person("asdfsf");//创建aa对象;

var bb=new

person("sdsd8999");//创建bb对象;

aa.sayhello();//通过对象直接调用方法;

bb.sayhello();

alert(aa.sayhello==bb.sayhello);

/script

script

type="text/javascript"

function

person(name){//基类构造函数;

this.name=name;

};

person.prototype.sayhello=function(){//给基类构造函数的prototype添加方法;

alert("hello i am

"+this.name);

};

function

emp(name.salary){//子类构造函数;

person.call(this.name);//调用基类的构造函数

this.salary=salary;

};

emp.prototype=new

person();//建一个基类对象作为子类原型的原型(原型继承)

emp.prototype.showm=function(){//给子类prototype添加方法;

alert(this.name+"$"+this.salary);

};

var aa=new

person("sdsf");//通过对象调用prototype的方法;

var bb=new

emp("23a",232);

aa.sayhello();

bb.sayhello();

bb.showm();

alert(aa.sayhello==bb.sayhello);

/script

私有变量:

script

type="text/javascript"

function

person(firstname,lastname,age){

//私有变量;

var_firstname=firstname;

var_lastname=lastname;

//共有变量;

this.age=age;

//方法;

this.getname=function(){

return (firstname+"

"+lastname);

};

this.sayhello=function(){

alert("hello i am

"+firstname+" "+lastname);

};

};

var aa=new

person("bill","tee",23);

var bb=new

person("sdd","ed",34);

aa.sayhello();

bb.sayhello();

alert(aa.getname()+"

"+aa.age);

alert(aa._firstname);//不能访问私有变量;unfined;

/script

每隔多少秒调用一次函数的方法:

setInterval(函数的方法名,1000);

其实看完javascript的东西,觉得他和java很像,也具有和java很像的东西:继承,封装,多态;

请问javscript的new问题?

对于new的理解,建议去看看李站写的《悟透javascript》 ,javascript中new的使用不能用c/c++的那种对象思维去理解了。在这里讲一点点你也只是半知半懂,所以直接建议你去看书。只是电子书!


网站题目:李站javascript,李站丰
URL标题:http://cdkjz.cn/article/dsdshhs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220