您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > WEB_悟透javascript
E=MC2“JavaScriptJavaScriptJavaScriptJavaScriptundefined,null,boolean,numberstringobjectJavaScriptfunctionNumber,String,Object,FunctionJavaScriptJavaScript!JavaScriptunfined,null,bool,number,string,objectfunctiontypeofundefined:typeof(undefined)undefinedundefinednull:typeof(null)objectnullobjectnullobjectboolean:number:typeof(NaN)typeof(Infinity)numberNaNNaNNaN!=NaNInfinity/Infinity=NaNstring:JavaScriptJavaScriptobjectfunctionobjectJavaScriptobjectJavaScript“JavaScriptJavaScriptvarlife={};for(life.age=1;life.age=3;life.age++){switch(life.age){case1:life.body=;life.say=function(){alert(this.age+this.body)};break;case2:life.tail=;life.gill=;life.body=;life.say=function(){alert(this.age+this.body+-+this.tail+,+this.gill)};break;case3:deletelife.tail;deletelife.gill;life.legs=;life.lung=;life.body=;life.say=function(){alert(this.age+this.body+-+this.legs+,+this.lung)};break;};life.say();};JavaScriptlifelifebodysaytailgilltailgilllegslung““JavaScriptJavaScriptJavaScriptJavaScriptJavaScriptfunctionfunctionproceduremethodJavaScriptfunctionfunctionfunctionmyfunc(){alert(hello);};alert(typeof(myfunc));typeof(myfunc)functionvarmyfunc=function(){alert(hello);};alert(typeof(myfunc));myfuncfunctiontypeof(myfunc)functionJavaScriptfunctionvarmyfunc=function(){alert(hello);};myfunc();//myfunchellomyfunc=function(){alert(yeah);};myfunc();//myfuncyeahfunctionmyfunc(){alert(hello);};myfunc();//myfuncyeahhellofunctionmyfunc(){alert(yeah);};myfunc();//myfuncyeahJavaScriptJavaScriptmyfuncJavaScripthtmlJavaScriptJavaScriptJavaScriptJavaScriptC++DELPHIC#JavaScriptfunctionfunctionobject()”functionSing(){with(arguments.callee)alert(author++poem);};Sing.author=;Sing.poem=Sing();Sing.author=;Sing.poem=Sing();;;SingSingauthorpoemauthorpoemSing()JavaScriptJavaScriptfunctionobject“varanObject={};//anObject.aProperty=Propertyofobject;//anObject.aMethod=function(){alert(Methodofobject)};////alert(anObject[aProperty]);anObject[aMethod]();for(varsinanObject)//////alert(s+isa+typeof(anObject[s]));functionvaraFunction=function(){};//aFunction.aProperty=Propertyoffunction;//aFunction.aMethod=function(){alert(Methodoffunction)};////alert(aFunction[aProperty]);aFunction[aMethod]();////for(varsinaFunction)//alert(s+isa+typeof(aFunction[s]));JavaScriptJavaScriptobjectfunctionJavaScriptfunctionobjectC++C#JavathisDELPHIselfVBmeJavaScriptJavaScriptthisthisC++C#JavathisthisJavaScriptthisthisJavaScriptthisfunctionWhoAmI(){alert(I'm+this.name+of+typeof(this));};//WhoAmIWhoAmI();//thiswindownameI'mofobjectvarBillGates={name:BillGates};BillGates.WhoAmI=WhoAmI;//WhoAmIBillGatesBillGates.WhoAmI();//thisBillGatesI'mBillGatesofobjectvarSteveJobs={name:SteveJobs};SteveJobs.WhoAmI=WhoAmI;//WhoAmISteveJobsSteveJobs.WhoAmI();//thisSteveJobsI'mSteveJobsofobjectWhoAmI.call(BillGates);WhoAmI.call(SteveJobs);//BillGatesthisWhoAmII'mBillGatesofobject//SteveJobsthisWhoAmII'mSteveJobsofobjectBillGates.WhoAmI.call(SteveJobs);I'mSteveJobsofobjectSteveJobs.WhoAmI.call(BillGates);I'mBillGatesofobject//SteveJobsthisBillGatesWhoAmI//BillGatesthisSteveJobsWhoAmIWhoAmI.WhoAmI=WhoAmI;WhoAmI.name=WhoAmI;WhoAmI.WhoAmI();//WhoAmI//thisWhoAmII'mWhoAmIoffunction({name:nobody,WhoAmI:WhoAmI}).WhoAmI();I'mnobodyofobject//WhoAmIthisthisfunctionJavaScriptthisthisthisthisthisJavaScriptthisJavaScriptthisBillGates.WhoAmI()SteveJobs.WhoAmI()thisthisJavaScriptJavaScriptJavaScriptObjectNotation(JSON)JavaScriptJSONvaro={};varperson={name:Angel,age:18,married:false};varspeaker={text:HelloWorld,say:function(){alert(this.text)}};varcompany={name:Microsoft,product:softwares,chairman:{name:BillGates,age:53,Married:true},employees:[{name:Angel,age:26,Married:false},{name:Hanson,age:32,Marred:true}],readme:function(){document.write(this.name+product+this.product);}};JSON{}”,”:”JavaScriptJSONJSONJavaScriptXMLJSONJSONJavaScriptevalJavaScriptJSONAJAXJavaScriptJSONJavaScriptnewfunctionMyFunc(){};//varanObj=newMyFunc();//newMyFunJavaScriptfunctionMyFunc(){};varanObj={};//MyFunc.call(anObj);//anObjthisMyFuncJavaScriptnewthisJavaScript“anObj=newMyFunc()”C++C#MyFuncJavaScript1234functionPerson(name){this.name=name;//this//this//this.SayHello=function(){alert(Hello,I'm+this.name);};SayHello567891011functionEmployee(name,salary){Person.call(this,name);this.salary=salary;//this//thissalary//};this.ShowMeTheMoney=function(){alert(this.name+$+this.salary);};//ShowMeTheMoney12131415161718192021222324alert(BillGates.SayHello==SteveJobs.SayHello);//falsealert(BillGates.constructor==Person);//truealert(SteveJobs.constructor==Employee);//trueBillGates.SayHello();SteveJobs.SayHello();//I'mBillGates//I'mSteveJobs//SteveJobs$1234varBillGates=newPerson(BillGates);//PersonBillGates//EmpolyeeSteveJobs};varSteveJobs=newEmployee(SteveJobs,1234);SteveJobs.ShowMeTheMoney();9EmployeethisPerson2122BillGatesPersonSteveJobsEmployeeconstructorthis()JavaScriptJavaScriptJavaScriptthisfunctionSayHello(){alert(Hello,I'm+this.name);};//SayHellofunctionPerson(name)//{this.name=name;//this//thisSayHelloSayHellothis.SayHello=SayHello;};varBill
本文标题:WEB_悟透javascript
链接地址:https://www.777doc.com/doc-5891018 .html