资源描述:
《javascript for object-oriented programmers》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、iTePub.Net-CollectJavaScriptforobject-orientedprogrammers589LicensedtojonathanzhengiTePub.Net-Collect590APPENDIXBJavaScriptforobject-orientedprogrammersTherearemanyroutesintobecomingaJavaScriptprogrammer,rangingfromgraphicdesigntoaser
2、iousprogrammercomingupfromthebusinesstiers.Thisappendixwon’taimtoteachyouhowtoprograminJavaScript—therearealreadymanygoodbooksandarticlestohelpyoudothat.WhatIintendtorecordhereareafewcoreconceptsthatwillhelpJavaandC#programmersmaketheleaptoJavaScriptprog
3、ramminginarelativelypainlessway.(ThesameistruetoalesserextentofC++programmers,butC++inheritsalotofstrangeflexibilityfromC,sothatJavaScriptshouldprovelessofashocktothesystem.)IfyouareaseriousenterpriseprogrammerwithagroundinginOOdesignprinciples,thenyourf
4、irstapproachestoJavaScriptmaybeoverlyinfluencedbyyourexperiencewithlanguagessuchasJavaandC#,andyoumayfindyourselffightingagainstthelanguageratherthanworkingwithit.Icertainlydid,andI’vebasedthisonmyownexperienceasaprogrammerandinmentoringothersalongthesam
5、eroute.JavaScriptcandoalotofcleverthingsthatJavaandC#can’t.Someofthesecanhelpyoutowritebettercode,andsomecanonlyhelpyoutoshootyourselfinthefootmoreaccurately!It’sworthknowingaboutboth,eithertomakeuseofthetechniquesortoavoiddoingthemunwittingly.Ifyouareco
6、mingtoAjaxfromastructuredOOlanguagesuchasJavaorC++,thenIhopethatreadingthisappen-dixwillhelpyouasmuchasIthinkitwouldhavehelpedmeafewyearsback!B.1JavaScriptisnotJavaWhat’sinaname?InthecaseofJavaandJavaScript,alotofmarketingandrel-ativelylittlesubstance.Ja
7、vaScriptwasrenamedfrom“livescript”atthelastminutebyNetscape’smarketingdepartment,andnowthenamehasstuck.Con-trarytopopularperception,JavaScriptisnotadescendentoftheCfamilyoflan-guages.ItowesalotmoretofunctionallanguagessuchasSchemeandSelf,andithasquitealo
8、tincommonwithPython,too.Unfortunately,it’sbeennamedafterJavaandsyntacticallystyledtolooklikeJava.Inplaces,itwillbehavelikeJava,butinmanyplaces,itjustplainwon’t.TableB.1summarizesthekeydifferences.TableB.1KeyfeaturesofJavaS