资源描述:
《You.Dont.Know.JS.Scope&Closures(上)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、ScopeandClosuresKyleSimpsonScopeandClosuresbyKyleSimpsonCopyright©2014GetifySolutions,Inc.Allrightsreserved.PrintedintheUnitedStatesofAmerica.PublishedbyO’ReillyMedia,Inc.,1005GravensteinHighwayNorth,Sebastopol,CA95472.O’Reillybooksmaybepurchasedforedu
2、cational,business,orsalespromotionaluse.Onlineeditionsarealsoavailableformosttitles(http://my.safaribooksonline.com).Formoreinformation,contactourcorporate/institutionalsalesdepartment:800-998-9938orcorporate@oreilly.com.Editors:SimonSt.LaurentandBrian
3、Mac‐CoverDesigner:KarenMontgomeryDonaldInteriorDesigner:DavidFutatoProductionEditor:MelanieYarbroughIllustrator:RebeccaDemarestProofreader:LinleyDolbyMarch2014:FirstEditionRevisionHistoryfortheFirstEdition:2014-03-06:FirstreleaseSeehttp://oreilly.com/c
4、atalog/errata.csp?isbn=9781449335588forreleasedetails.NutshellHandbook,theNutshellHandbooklogo,andtheO’ReillylogoareregisteredtrademarksofO’ReillyMedia,Inc.YouDon’tKnowJavaScript:ScopeandClosures,andrelatedtradedressaretrademarksofO’ReillyMedia,Inc.Man
5、yofthedesignationsusedbymanufacturersandsellerstodistinguishtheirprod‐uctsareclaimedastrademarks.Wherethosedesignationsappearinthisbook,andO’ReillyMedia,Inc.wasawareofatrademarkclaim,thedesignationshavebeenprintedincapsorinitialcaps.Whileeveryprecautio
6、nhasbeentakeninthepreparationofthisbook,thepublisherandauthorassumenoresponsibilityforerrorsoromissions,orfordamagesresultingfromtheuseoftheinformationcontainedherein.ISBN:978-1-449-33558-8[LSI]TableofContentsForeword...................................
7、...................vPreface.......................................................vii1.WhatIsScope?..............................................1CompilerTheory1UnderstandingScope3NestedScope8Errors10Review112.LexicalScope..............................
8、................13Lex-time13CheatingLexical16Review213.FunctionVersusBlockScope.................................23ScopeFromFunctions23HidinginPlainScope24FunctionsasScopes28BlocksasScopes33Review394.Hoisting.............................