JavaScript 语言精粹(修订版)


࣫ҀЁᮄӳϮॄࠋ᳝䰤݀ৌ ᳡ࡵ⛁㒓˖˄010˅88258888DŽ 䋼䞣ᡩ䆝䇋থ䚂ӊ㟇 zlts@phei.com.cnˈⲫ⠜։ᴗВ᡹䇋থ䚂ӊ㟇 dbqq@phei.com.cnDŽ 㘨㋏ˈ㘨㋏ঞ䚂䌁⬉䆱˖˄010˅88254888DŽ ޵᠔䌁ф⬉ᄤᎹϮߎ⠜⼒೒к᳝㔎ᤳ䯂乬ˈ䇋৥䌁фкᑫ䇗ᤶDŽ㢹кᑫଂ㔎ˈ䇋Ϣᴀ⼒থ㸠䚼 ܗ ᅮӋ˖49.00 ॄ⃵˖2012 ᑈ 8 ᳜㄀ 1 ⃵ॄࠋ ᓔᴀ˖787×980 1/16 ॄᓴ˖11 ᄫ᭄˖258 गᄫ ࣫ҀᏖ⍋⎔ऎϛᇓ䏃 173 ֵㆅ 䚂㓪 100036 ߎ⠜থ㸠˖⬉ᄤᎹϮߎ⠜⼒ 㺙䅶˖ ॄࠋ˖ ᇕ䴶䆒䅵˖Karen Montgomery 䋷ӏ㓪䕥˖Ҭ ⵓ ㄪߦ㓪䕥˖ᓴ᯹䲼 Ё೑⠜ᴀ೒к佚 CIP ᭄᥂Ḍᄫ(2012)㄀ 171680 ো Ă ĸ䍉Ă Ĺ䛶Ă ċ. ķJAVA 䇁㿔ˉ⿟ᑣ䆒䅵 Č. ķTP312ܟĉ. ķJĂĊ. ķ ISBN 978-7-121-17740-8 кৡॳ᭛˖JavaScript: The Good Parts ⬉ᄤᎹϮߎ⠜⼒ˈ2012.8 ᖋ˄Crockford,D.˅㨫˗䍉⋑⃷ˈ䛶ᄺ吡䆥. üׂ䅶ᴀ. ü࣫Ҁ˖⽣ܟ㔫ܟ˅JavaScript 䇁㿔㊒㊍ /˄㕢 ೒к೼⠜㓪Ⳃ˄CIP˅᭄᥂ ⠜ᴗ䌌ᯧড়ৠⱏ䆄ো ೒ᄫ˖01-2009-0879 ᮍᓣ໡ࠊ៪ᡘ㺁ᴀкⱘӏԩ䚼ߚDŽ ᴀкЁ᭛ㅔԧ⠜ϧ᳝ߎ⠜ᴗ⬅ O’Reilly Media, Inc.ᥜќ⬉ᄤᎹϮߎ⠜⼒ˈ᳾㒣䆌ৃˈϡᕫҹӏԩ All rights reserved including the rights of reproduction in whole or in part in any form. rights to publish and sell the same. Industry, 2012. Authorized translation of the English edition, 2012 O’Reilly Media Inc., the owner of all Simplified Chinese edition, jointly published by O’Reilly Media, Inc. and Publishing House of Electronics 978-0-596-51774-8 JavaScript:The Good Part © 2008 by O’Reilly Media, Inc. 䍞໻Ꮬˈ䖭ᴀкህᰃᓔྟDŽ 䇏ˈᑊϨ䳔㽕ড໡䯙䇏DŽᄺдǃ⧚㾷ǃᅲ䏉໻Ꮬⱘᗱᛇˈ៥Ӏᠡৃ㛑キ೼ᎼҎⱘ㙽Ϟˈᠡ᳝ᴎӮ䍙 ໛Ңџ JavaScript ᓔথⱘҎ䯙ޚ䖭ᰃϔᴀҟ㒡 JavaScript 䇁㿔ᴀ䋼ⱘᴗ࿕к㈡ˈؐᕫӏԩℷ೼៪ 䗮䖛ᅗⱘẔ偠ˈ㛑᳝ᬜഄֱ䱰៥Ӏⱘҷⷕક䋼DŽ ᅗӀDŽ᳔ৢ䖬ҟ㒡њ JSLintˈܡ԰㗙䖬䗮䖛䰘ᔩ߫ߎњ䖭䮼䇁㿔ⱘ↦⯸੠㊳㉩䚼ߚˈϨਞ䆝Դབԩ䙓 㕢ⱘ⡍ᗻ䖭 9 Ͼᮍ䴶ᴹਜ⦄䖭䮼䇁㿔ⳳℷⱘ㊒ढ䚼ߚˈ䗮䖛ᅗӀᅠܼৃҹᵘᓎߎӬ䲙催ᬜⱘҷⷕDŽ ੠䴲ᐌᆠ᳝㸼⦄࡯ⱘ䇁㿔DŽ԰㗙Ң䇁⊩ǃᇍ䈵ǃߑ᭄ǃ㒻ᡓǃ᭄㒘ǃℷ߭㸼䖒ᓣǃᮍ⊩ǃḋᓣ੠Ӭ ᢑ⾏ߎϔϾ݋᳝᳈དৃ䴴ᗻǃৃ䇏ᗻ੠ৃ㓈ᡸᗻⱘ JavaScript ᄤ䲚ˈ䅽Դⳟࠄϔ䮼Ӭ䲙ⱘǃ䕏䞣㑻ⱘ ໪ˈг䆕ᯢњᅗ݊ᅲᰃϔ䮼Ӭ⾔ⱘ䇁㿔DŽDouglas Crockford ೼ᴀкЁ࠹ᓔњ JavaScript ⊒∵ⱘ໪㸷ˈ 䅵ˈԚ䱣ⴔ Ajax ⱘࠄᴹˈJavaScriptĀҢ᳔ফ䇃㾷ⱘ㓪⿟䇁㿔ⓨবЎ᳔⌕㸠ⱘ䇁㿔āˈ䖭䰸њᑌ䖤П JavaScript ᳒ᰃĀϪ⬠Ϟ᳔㹿䇃㾷ⱘ䇁㿔āˈ಴Ўᅗᢙ䋳໾໮ⱘ⡍ᗻˈࣙᣀ㊳㊩ⱘѸѦ੠༅䋹ⱘ䆒 ݙᆍㅔҟ ——Linux Journal ᩲǍÿ ԝTimͫ˫ඈʷ൓ᦐᤥહ̀࠵᡹ὊᏫ˅దї൓ᦐ௧ʷ᫅ԁᤲᄊ఻͘Ὂࡊኮܸ᡹˷ˀ ᮏ᣿ڀ᡹ʽ᥅҂࡮᡹԰Ὂᡌ࠵᡹὆࡮᡹὇ ǍýښYogi BerraᄊथᝬԝϢ̀὘ üݠ౧Ϳ ોིڡþTim௧ͯྲቡ࿘ᛡᄊ׸̡Ὂ̵ˀАஊᅋ̆త᫂ᤊnjతࣹ᫫ᄊ᜽᧙ࣳ˅ѭࠄ ——Irish Times þʷవ O’Reillyᄊ˺ࡃ̽᛫ʷ˔దၹnjదҒ᤭njᭊ᜶ߦ˸ᄊ˟ᮥǍ ÿ ——CRN þO’Reilly Conference௧ᐑᬷТ᪄নਇᮗ᛾ᄊፐࠫЧᔵǍ ÿ ——Business 2.0 ҬǍÿ þO’Reillyћώʷጇѵ὆ᄾ࣏మेѺੈ˷ਇ҂̀὇᭤јਇขथቡ̀஝ᄈʺᎿЋᄊˊ ——Wired þO’Reilly RadarӰࠇద԰ᄋᇀǍ ÿ Ϯ⬠䆘䆎 ૰ଉăڦႎظ૙౒ĊĊ႑တ๟घ݀ڦᄩۯփ੗ ݒᆙକࠅິۼ೗ׂڦ Lj௅ᅃၜ O’Reillyײခईኁ௬๲ੜޜࢽă࿮ஃ๟ཚࡗກढ؜ӲLjሞ၍ ऺ໙ऐᆩڦߴ೵ཚڿدኪ๎ڦጆॆބ჋ስLj O’Reilly ၄ሞ࣏ॽံڦፕྺरຍට๗इൽ႑တ ߫ంႠາၙăڦႎׂᄽظฆᄽଶႰLjࠌཞ௮ࣼ؜ਸڦपटਜ਼ࢅߛቒᇺድגܠࣷण਋କዚރࢅ ࣷᅱڦ ă O’Reillyټ౨ڦ঳႑တᇑටۀዖႚ๕ܠཚࡗںǗࠅິᅃස़ྫބዷᄲံڦDIY ߫ం ૬କ Make ሗኾLjܸٗׯྺظᅜُంఁǗۯࣷLjᅜ዁ᇀਸᇸ෉ॲሏރஓپਸݣᇸڦᆖၚศᇺ ᅃ߲ฆᄽྪበDŽ GNNDžǗፇኯକڼॺظ࿿ກđ ǗۯĐڦઠ߫ంႠټO’Reilly ྺ෉ॲਸ݀ටᇵ ăٷሰࢅ݀ᄙ࠼ظĂڞבڦႎظܔቛ؊஢କ݀ڦ ᇑኁLj O’Reilly֖ڦፕྺरຍม൶ዐऄሂ ᆌᆩăڦႎ੔रܔ႑ࡽđઠِघมࣷڦఫၵĐဦྲٷरຍ൵๞ĊĊཚࡗݣڦ்࠲ጀኈኟዘᄲ ጣ࿄ઠLjܸ࿢ظपटਜ਼்ኟሞਸגኁăۯ९ኤኁࢅླྀڦ๟മᄂ݀ቛۼ౎ਸ๔LjO’Reilly ᅃ኱ ႎኪ๎ăጲ 1978ظխدݛ๕ڪခĂֱۙჺ৯ࢅࣷᅱޜO’Reilly Media ཚࡗ཮ກĂሗኾĂሞ၍ O’Reilly Media, Inc.঻ถ                       C. Twildoă ڦߴअऺ்ǖClementĂPhilbertĂSeymoreĂStern ࢅփ੗ᅍྮ ዂ৤! ! ! ! ! ! !   ඹԨ๟ኰሴăాڦ݋ᅳԨກں࿢்ᄺ৑໯ీཚࡗᅳኁጀ৊ႜକՔጀăፕྺᅃఁᅳኁLjዒํ ঢ়ᄓࢅຕ਍Ljڦဃăᅃၵᅙঢ়ࡗ้ٱਿဃLjႪኟକ 80 ᇆ߲ڦቷዐᆈ࿔ܔӲԨLjڦ۩ኄْႪ ዿӕLj࿢੺ᄲጽ༶କăٶ৽ُ čč ࡚ጱᄺইิକăڦ࿢ LjڹՎࣅă࿢঳କࣿLjጎႪକݝጱLjሞඁ౎౎ڦٷටิཞᄣ݀ิକዘڦᇀ࿢ܸჾLjኄ 4 ౎࿢ ᆶำăںዀ በሞᄇ঄໼ฉඐ๟ᏃᏃܸ༌LjڍఢᐣăڦरຍටᇵۅࡻDžăට࢔ҾৢLjੂฉඁᆶఫ஺ᅃڦࢲጱ ࣏๟ାڢ઻ڥቷೌLjਥڦକ໱࿄ାࢲጱڟஏ෕ࢲጱDŽࢫઠ࿢ੂڦޅLjାጣઙٷ࿢ၙၡዐߛ Ljժࢅ໱ࢇᆖା౒ă໱Բڢକ઻ڟࣷฉLj࿢ࢅბ 卹ᆶ႞ᇜٷ Qcon ڦ2009 ౎Ljሞԛ৙ਉႜ ES6 ዐă ᆫႯາၙࣷ؜၄ሞڦԨກዐܠ߸ځĐ HarmonyDŽࢅၿDžđLj೺ڦఁጴ๟࿢்࿮ԲຄဒڦዐLj໲ ES ӲԨDŽ ES6Džኟሞ዆ۨ ڦپဃăူᅃٱࣷಙ؜ۼඇਆՎଉईኁ with ᇕਔLjڦ๑ᆩ࿄ำ௽ ՔጚፇॲǗምԲස ES5 ኧ׼Đჹ߭đఇ๕Ljሞُఇ๕ူLjڦ ES5 ֑భLjԲස JSON ׯྺ ES5 ᅃၵ৛ࣀᄺԥڦLj࿢ኈփᇼᅪၟႀ Java ᅃᄣႀ JavaScriptăԨກዐںፕᆩăႇཀႇڦٷକዘ ᅱഐבڦڢED4DŽJavaScript 2.0DžLj਍ຫ઻ ڦକࡗᇀघ৊پDŽES5DžLjኄ߲ӲԨሞፌࢫ้ਗ਼ൽ ߲ӲԨ 5 ڼڦ ք ECMA-262݀ڹECMALjዕᇀሞ 2009 ౎౎ ڦӲԨ݀քٷᅙঢ় 10 ౎࿄ᆶዘ ᆶेă؍໲ླྀܔԨටᄺඓํڢJavaScript ৛ࣀጱणă઻ ڦᄲ ፕኁ Douglas CrockfordDž໯ၙڦDŽ࿢்ຳူ૛ኄᄣፎ׬Ԩກڢ৽๟઻ގ༬ႠLjݠڦԨᇕჾ গپ၄ܠୀࢅሧ೩Lj࣏ཁेକ࢔۾ڦڟԨກዐ༵ܠକ࢔أ৛ࣀLjඁڦဌ๭କ JavaScript ᇕჾ Lj໲ิڐڦ ᅜമ CoffeeScriptܠ๟ 2 ౎ڦᅃ༵ڥଶᇘă࣏ኵײՊ܋ခഗޜڟJavaScript ணჽ ؜၄Lj߸๟ඟڦ ࿋නᅮ༵ߛă NodeJSںڦ೵तLjJavaScript ሞ Web ਸ݀ଶᇘዐڟڥደॷ બഗ৪ෘLj HTML5៓ڦगၡLjໜጣႎᅃ୾ڦቛີࡹுᆶ३໏݀ڦ ሞኄ 4 ౎૛Lj JavaScript ଚਉ؜ઠăں๚Lj൩ඹ࿢ᇕ࿮୿ْܠक़૛Lj݀ิକ࢔้ڦ܌ኄ܎փ׊ᄺփ Ljփኪփਥ้क़৩඗ᅙঢ়ࡗඁ੺ 4 ౎କăڟᅳኁႾLj࿢֍ᅪ๎ڦӲ 1 ڼዘੂڟ኱ ምӲᅳኁႾ vii   2012 ౎ 8 ሆ 5 නஓጴᇀࡴዝ ൕă ޴ڦཌ೑Lj൩ᇱଌᅃ߲௚૿࡚ጱْܠڦࣄՊडቧؾᇐ઻฾Lj໱ඹඨକ࿢֧ڦߌႇԨႪ۩Ӳ ࿔ጴăڦှာႀူ܏Ⴤڥ֍ᆶ ৛ೃ૰৑৽փ੝ລඁă໯ᅜLj࿢ኻᆶሞ࡚ጱྟฉຄລࢫLjڟLj௅ཀփ఺ۅᆫڦ׶࿢ဠ࣌Ҿৢ ࣆLjఫ৽๟໱ுᆶीڦ๟ሧ೩ۅ৛ࣀLjසࡕᅃۨᄲຫᆶᅃڦକ࿢ࢅ໿໿د࡚ጱLj৽ᅍڦ࿢ ăڦາၙ๟փࣷࡗ้ڦĐൽഄ৛ࣀLjചഄሧ೩đڍႪ۩LjْܠඹᄺႹ࣏ႴᄲాڦඁLjԨກዐ ቛူ݀ں࿢ၙLj JavaScript ࣏ࣷփཕڍă݆ੂڦࢆ࿍৛ࣀĂࢆ࿍ሧ೩ᆶጲमܔ௅߲ਸ݀ටᇵ ৛ࣀጱणăᄺႹLjڦঢ়ᄓ༵଀ڦፌਸཀྵLj৽ᅙঢ়՗௽ǖԨກాඹ๟໱ߵ਍ጲमڦሞԨກڢ ࡚ጱăഄํLj઻ڦJavaScript ጱणLj৽සཞ࿢ੂጲम ڦ๫໱༵଀ڢ࡚ጱă࿢၎႑઻ڦጲमځ ੂں࿮݆ྜඇਜ਼࠵ۼ޴జ಄๟ڦԐԐLjཀူڦ࡚ጱ๟๘হฉፌ೏ଋڦ࿢ڥሞ࿢ᄅ૛Lj࿢ਥ ൱ኤăڦܸݥ੔ბ ߲ටዷ࠵ੂ݆LjڦڢߵԨ৽๟઻ۅຫᆶၵ࠵ںፌॅํ७Ljᆶටฯ዁ჾًघଜڦ ๟ JavaScript փۅLjᆶටණྺԨກᅃၵ࠵݆ੂڦևݴాඹ༵؜କփཞڦԨກܔᄽহཞႜLjڦད࿕ࡔాྔ ْܠևݴă࿢ᄺሞփཞׇࢇڦਸ݀ঢ়ᄓᆶ؋཭ڦᅃၵᇑጲमڟዐLj࿢்ሼᇜײࡗڦሞ݋ᅳ ምӲᅳኁႾ viii!϶  ӻዺă࣏ᆶዜᶄٷఎڦዐߴᇎ࿢்ײՊडቶ๗ྰሞԨກ݋ᅳࡗڦۅፌࢫLj࿢ᄲߌႇձ࿔๫ ฾౥ටLjౢᆶዖࢭǛđٷĐ ฾ƽٷူ႐ઠॕ׼ბသࢅჺ৯Lj࿢்ཞᄣᄺ੗ᅜׯྺ ݛ݆യڦरຍLjժᆩ੔ბڦፌ๢ࢇ߾ፕईጲमፌߌ႗඀ڟăቴۨޏඇ๭ईඇಎڇቷںٖ஬ ႎरຍĂႎ૙౒้Ljփᄲڦኄၵ֫؜փ൬ܔ࿢்௬ړIT ଶᇘઠຫ߸޿සُă ڦනႎሆᅴܔ ᇑݛ݆Lj܈ბသༀڦକᅃ߲ഔ๖Lj Đൽഄ৛ࣀLjඁഄሧ೩đԨ৽๟മටߢ໕࿢்ڟڥዸፕᄺڦ ฾ٷ฾ă࿢ཚࡗ݋ᅳٷڦထྭጲमᆶᅃཀׯྺగ߲ଶᇘۼਸ݀ටᇵڦ࿢ၙ௅ᅃ߲ඤҺरຍ ኁኄᄣፔă܁ڦ࿢்ཞᄣླྀ४໯ᆶ ăڦ܁LjኄԨກ๟ႴᄲݒްለॆٷLj๭इ೤ݿă Crockford ሞമჾዐߢঽײࡗڦमॠ༪ࢅბသ ᄺׯྺጲײࡗڦറԋࢅփྜኝLjᇀ๟݋ᅳڦጲमኪ๎௬ڟ࿢ศਗ਼ߌ๴ڦJavaScript ೤ྺକ঴ ܔዐ࿢ᄺ׉ߌࡱჿLjᇱઠጲᐴײࡗڦඹඐݥ׉ݿࢩࢅศ෇ă݋ᅳాڦ׶ሜڍኄԨກ࢔ԋLj ๬ݑహࢅҾඇᆆᆭăۙڦ܋࿮ܠༀႠLjᆼీ௨ඁႹۯڦጝሁ ՗၄૰ࢅڦٷLj৽़ీ๑ᆩ JavaScript ഽײݔؑዐՊڦ৛ࣀጱणăਸ݀ටᇵኻᄲሞኄ߲ጱण ڦ ঢ়ᄓ༵଀؜କ JavaScriptڦბ๎ࢅݿ޷ڦ᥂փᄄ᥀ă Crockford ྺُೞ঺໱࠽ձڍLjه᥂ ණLj JavaScript ጲวඓํ٪ሞጣփณޏᆇׯକതጴLjඟႎ๮்ٗᅃਸ๔৽ጽฉକഇ཰ăփ੗ ኟཥLjྺތᆩ૩ڦກढӝḡগڦଉփ޶ሴඪٷ๟Lj࣏ᆶڦ૸ॏփਾǗ߸ሧߞڥJavaScript ၂ ฆᄽᇱᅺࢅࡀݔവඍߴ JavaScript ኄோᇕჾ௏ฉକᅽᆖǗ Copy+Paste ๕રᆩᄺඟڦăራ೺܁ ቴઠኄೊ࿔ቤDŽ http://javascript.crockford.com/javascript.htmlDžժጮဦለۼኁ܁໯ᆶڦኄ૛ ڟᇕჾė ăॺᅱੂڦᅃೊ࿔ቤĊĊĖ JavaScriptǖ๘হฉፌԥဃ঴ڦCrockford ሼႀࡗ࢔ዸఁ ਸ݀ᇕჾăڦኟනᅮׯྺࢻ૴ྪዐፌ೵तࢅፌዘᄲ փ׶ණLj JavaScriptڥनՍසُLj ᄺփڍ ߌ๴߸ྺศਗ਼ăڦُܔ ਸ݀ፇLj܋മڦ੨Ԙྪࢅ༨Ԑྪ JavaScript ٪ᆶೋ९ăൖߤࢅ࿢Ljݴ՚޶ሴჯࢸ ܔਸ݀ටᇵڦጨศܠ၄ሞLjᅈ඗ᆶ࢔ڟᅃ኱ ăॆٷ݋ᅳ؜ઠժླྀ४ߴڥ၃LjᄺኵޅڦኮፕLjनՍ๟ஶጣݖፍۆ฾ঢ়ٷڦኄᄣڍ๟ݖፍă ࢔ሧߞሶڥᅙLjܸӝᅃԨࡻກ݋ᅳܸٱກኻ๟ݖڦࡔঞᇣॆDžሼঢ়ຫࡗǖႀକᅃԨ࢔ሧߞ ඵ႞LjᅃՉᄺ๟৔৔ၭ႐ăᅺྺञܻն༬g࡛༬DŽெڦݴྤڟፕ೗LjᅃՉ๟ߌڦ฾ٷ݋ᅳ ฾ăٷDouglas Crockford ๟ᅃ࿋ ᅳኁႾ ix   2008 ౎ 11 ሆᇀࡴዝ׭ဇ ᅳኁǖቶሷႌDŽၭகDžLjᒉბ待DŽൖߤDž ࡻăڦ౰ටLj࣏๟փᄲඁፔ݋ᅳڦᆶᅃ࿋฀঴ටᅪ ă၎႑࿢LjසࡕేวࢫுڦDŽ޶ሴথ࠶ߡݯDž๟ᅃۨᄲ༬՚ߌႇڞଶڦ඗Ljॆዐړሧ೩đă Đ৛ࣀĂचોĂڦĐࡻĂዐĂ࣋đ༬Ⴀ݋ᅳྺ߸ཌྷൎڦ ໳ߴ࿢ॺᅱLjӝ JavaScriptڦ֑ዐྔ ၬࢁLj๟ձڦ ཞ๚Ljઠጲெࡔ NCSUڦၲำඟටԢߌൕൎă࿢࣏ᄲߌႇ࿢ڦ઻฾Lj໳ຢશ ᅳኁႾ x!϶  ၡ ..............................................................................................................................26ܔࡧຕ ቤ ࡧຕ ................................................................................................................ 26 4 ڼ ३ณඇਆՎଉ࿫ක ...............................................................................................................25 24...................................................................................................................................... أ෸ ஼ਉ ......................................................................................................................................24 ݒพ ......................................................................................................................................23 ᇱ႙ ......................................................................................................................................22 ᆅᆩ ......................................................................................................................................22 ߸ႎ ......................................................................................................................................22 ॠ໭ ......................................................................................................................................21 ၡጴ௬ଉ ..........................................................................................................................20ܔ ၡ ................................................................................................................ 20ܔ ቤ 3 ڼ ࡧຕ ......................................................................................................................................19 ጴ௬ଉ ..................................................................................................................................18 ๕ ..................................................................................................................................15ٳ՗ ᇕਔ ......................................................................................................................................10 8.................................................................................................................................... زޙጴ ຕጴ ........................................................................................................................................7 6.................................................................................................................................... ޙՔ๎ ੣ӣ ........................................................................................................................................5 ቤ ᇕ݆ .................................................................................................................. 5 2 ڼ ๬ᄓׇ .................................................................................................................4ڦڇᅃ߲० ݴဆ JavaScript.......................................................................................................................2 ྺ๊஺ᄲ๑ᆩ JavaScript.......................................................................................................2 ቤ ৛ࣀ .................................................................................................................. 1 1 ڼ മჾ .................................................................................................................................xv Table of Contents ణ୤ xi Number .................................................................................................................................84 Function ................................................................................................................................83 Array.....................................................................................................................................77 ቤ ݛ݆................................................................................................................. 77 8 ڼ ᇮ໎ ......................................................................................................................................71 ঳ࠓ ......................................................................................................................................69 ᅃ߲૩ጱ ..............................................................................................................................65 ๕..................................................................................................... 64ٳቤ ኟሶ՗ 7 ڼ ๔ኵ ..........................................................................................................................62؛ኸۨ ݛ݆ ......................................................................................................................................60 ݛ ...................................................................................................................60ںڦඹᅟंၫ ஼ਉ ......................................................................................................................................59 59...................................................................................................................................... أ෸ 58...................................................................................................................................... ܈׊ ຕፇጴ௬ଉ ..........................................................................................................................57 ቤ ຕፇ................................................................................................................. 57 6 ڼ ևॲ ......................................................................................................................................55 ࡧຕࣅ ..................................................................................................................................51 ᇱ႙ ......................................................................................................................................50 49.......................................................................................................................... ޙၡຫ௽ܔ ࿁ૌ ......................................................................................................................................46 ቤ ी׶................................................................................................................. 46 5 ڼ ऻᅬ ......................................................................................................................................43 ੐૛ࣅ ..................................................................................................................................43 प૴ ......................................................................................................................................42 ఇ੷ ......................................................................................................................................40 ࣮ۙ ......................................................................................................................................39 ԿԈ ......................................................................................................................................36 ፕᆩᇘ ..................................................................................................................................36 ࡃ ......................................................................................................................................33ڿ ࠀీ ...................................................................................................................32ڦક؊ૌ႙ ᅴ׉ ......................................................................................................................................31 ݓ࣮ ......................................................................................................................................31 ֖ຕ ......................................................................................................................................30 ۙᆩ ......................................................................................................................................27 ࡧຕጴ௬ଉ ..........................................................................................................................27 ణ୤xii!϶ ໭ᆅ .............................................................................................................................. 149 ޹୤ E JSON............................................................................................................... 138 ޹୤ D ᇕ݆཮........................................................................................................... 127 ޹୤ C JSLint ............................................................................................................. 115 ޹୤ B ሧ೩ ............................................................................................................... 109 ୀ ............................................................................................................... 101۾ ޹୤ A ༬Ⴀ................................................................................................... 98ڦቤ ᆫெ 10 ڼ ߭ ........................................................................................................ 94ޅஓپ ቤ 9 ڼ String.....................................................................................................................................88 RegExp .................................................................................................................................86 Object....................................................................................................................................85 ణ୤ ϶!! xiii ऺ໙ऐՊஓă໲்ԈઔంସĂದዃĂՎଉĂຌႠĂ॰Ă൩൱ĂࡧຕĂݛڦ՗๖࠽ᅭฉ ੻ጴ༹DŽ Constant widthDžڪ ՗๖ጆᄽَࣹĂ૾থDŽ URLDžĂ࿔ॲఁࢅ࿔ॲકቛఁă ၽ༹DŽItalicDž Ԩກ๑ᆩူଚಇӲሀۨă Conventions Used in This Book ሀۨڦԨກ ޲؜ॽࣷᆶ໯࣮ԒăڦLj൩՚ਊෟLjే܁փݒްለڥ໲ܸփ ඹăසࡕྺକ૙঴ాڦଉٷ௢णLj໲Ԉઔକۅኪ๎ڍኄփ๟ᅃԨ෯ࠩກăኄԨກ໚඗ԋLj ᇕჾኮᅃăڦ๟ JavaScriptLj໲ኻ๟ Web ਸ݀ኁՂႷቨ࿥ ৽ڦກăԨກ࠲ጀڦײ๟ُກݥԵກăኄᄺփ๟ᅃԨ࠲ᇀ Ajax ई Web ՊڍກLjڦPartsDž ᅃ঩܎ė DŽJavaScript: The Firstڼă ࿢ထྭగཀႀᅃԨঢ ĖJavaScriptǖڦბኁ؛ኄԨກփ๟ႀߴ ဇă۫ڦኄԨກৈԈࡤఫၵኈኟዘᄲ ăݒኮLjڟᅃൎLjఫၵ۫ဇే࢔ඹᅟሞྪฉቴڦڢ঻ถă໲փԈࡤేထྭኪڦႜඇ௬ܸၘ৑ ࠰Მ৊ڦኄோᇕჾࢅ໲ܔደօฉ๮Ljბࣷසࢆፇࢇ߲߳ևݴăኄփ๟ᅃԨ֖੊ກLj໲փࣷ ፇׯևݴLjժ൐ඟేڦາၙă࿢ॽቛ๖ኄோᇕჾײՊڦ ణՔ๟ӻዺేბသ JavaScriptڦԨກ ăڦᇕჾLj໲๟ᅟᇀቨ࿥ڦ๟ፕྺᅃோൟଉपڍ؜ಈLj ᇕჾă໲ᆶ้ࣷփӀ׉૙ڦସට৚ჲڥٷă JavaScript ๟ᅃோഽڦႾᇵጚԢײڦ঴ኄோᇕჾ ጚԢ߸ศ෇କڍႾᇵă໲ᄺ๟ྺఫၵᆶጣ JavaScript ෇ோঢ়ᄓײڦஶ၃৊෇ JavaScript ๘হ ኁ๟ఫၵᅺྺ౾඗๚ॲईࡻആ႐ൻ๑ܸ๯ْ܁ڦກă ໲ڦᇕჾײኄ๟ᅃԨ࠲ᇀ JavaScript Պ ĊĊྰ૸Ą෩๗ԲჱLjĖዙဲᅁኮ௔ėDŽA Midsummer Night’s DreamDž ዔă؛ڦٚറरᅝLjఫ֍๟࿢்ۅኻ๟ၙ၂ ፍ൩ᇱଌăԨ๟؜ጲᅃ݊ࡻᅪLjڥᄲ๟ᆶ໯ Preface മჾ xv   සࡕేၙ৽Ԩກ݀՗ೠஃईᆶඪࢆᅑ࿚Lj৤൩૴ဣ؜Ӳมă How to Contact Us සࢆ૴ဣ࿢் ӄă௨ݯ๬ᆩ൩ݡ࿚ http://safari.oreilly.comăٴڟ੺໏ቴ ႑တ้ڦஓᄣԨĂူሜగၵቤবĂሞేႴᄲፌጚඓࢅन้پॖरຍກढĂ२ൎࢅቕཌྷۥڦ ঴ਦݛӄă໲๟ᅃ߲Ⴕె཮ກ࠷Ljඟ౞੗ᅜൟ຿໇ლׯഥฉྤڦጱກ߸ࡻۉSafari ༵ࠃକԲ ُກᄺ੗ᅜཚࡗ O'Reilly Network Safari Bookshelf ሞ၍इൽă Safari®૴ऐ٘ກ཮ՔLjఫᅪ࿆ጣ ڟ௬ฉੂހڦरຍ཮ກڦසࡕేሞేፌဠҺ Safari®ሞ၍཮ກ permissions@oreilly.com ૴ဣ࿢்ă Ⴙ੗ݔྷLj൩ໜ้ཚࡗڦᆅᆩईኄ૛ߴ؜ړ؜କኟג๑ᆩڦஓپ๖૩ܔڟසࡕేߌ Inc., 978-0-596-51774-8.đă ກࡽDŽISBNDžă૩සǖĐJavaScript: The Good Parts by Douglas Crockford. Copyright 2008 Yahoo! փഽ൱ጀ௽႑တઠᇸăᅃཉ႑တઠᇸཚ׉ԈઔՔ༶ĂፕኁĂ؜ӲኁࢅࡔाՔጚڍ࿢்ሢง ăڦ ዐ๟ႴᄲႹ੗ڗ೗࿔ׂڦేڟஓժ෇پᆩ૩ڦଉٷăӝԨກዐڦ࿚༶๟փႴᄲႹ੗ٴઠ࣮ ஓپăཚࡗᆅᆩԨກࢅᆩ૩ڦ࠼ಎDŽ CD-ROMDž๟ႴᄲႹ੗ڦ๳ࢅොք O’Reilly ກዐᆩ૩ ă؜ڦႾ๟փႴᄲႹ੗ײஓႀᅃ߲پब܎ڦ࿮Ⴗ૴ဣ࿢்इൽႹ੗ă૩සLj๑ᆩઠጲԨກ ஓăేپڦዐ๑ᆩԨກዐڗႾࢅ࿔ײኄԨກ๟ྺକӻዺేፔࡻ߾ፕăᅃӯઠຫLjే੗ᅜሞ Using Code Examples ஓᆩ૩پ ໭ᆅ໯ଚᄻஓྺᇱᆈ࿔Ӳᄻஓă ڦLjԨກ܁ቷለܔኁᇑᇱᆈ࿔Ӳ཮ກ܁Đ đ՗๖ᇱກᄻஓLjՍᇀڦتዐ࿔Ӳກዐൎ੨ ంସईഄ໱࿔Ԩăڦ՗๖ᆌ޿ᆯᆩࢽӀቷጴ௬๼෇ ੻༹ٚDŽConstant width boldDžڪ ՔധĂࢢࢅ࠲॰ጴă ႾĂ XML ᇑ XHTMLײ૙تၡĂ๚ॲĂ๚ॲܔ݆Ăૌ႙ĂૌĂఇ੷ĂຌႠĂ֖ຕĂኵĂ മჾ xvi!϶  Mary TreselerĂSimon St.Laurent ࢅ Sumita Mukherjiă ڦසُຩ૧ڥᆮഄ๟๑๚൧Վ ໯ᆶׯᇵă ࿢ᄺᄲႇႇ O’Reilly Media, Inc.Ljڦ ݛ߾ፕLjႇႇࡗඁࢅ၄ሞሞ Ajax Strike Forceں ڦႇႇჯࢸࠅິDŽ Yahoo! Inc.DžLjᅺྺ໲ߴ࿢้क़ඁٗ๚ኄ߲ၜణLjժඟ࿢ሞᅃ߲සُኮԀ Shattuck ࢅ Bill Edneyă ට்Lj༬՚๟ Chip MorningstarĂRandy FarmerĂJohn LaĂMark MillerĂScottڦ৛ࣀܠฉᆶ࢔ ႇႇఫၵཞ࿢ᅃഐሞ Electric Communities ࢅ State Software ߾ፕժӻዺ࿢݀၄ኄோᇕჾํा SoudersĂBill ScottĂJulien LecomteĂStoyan StefanovĂEric Miraglia ࢅ Elliotte Rusty Haroldă ๟໱்ߋሞກ؜Ӳኮമፔକኄ߲๚൧ăႇႇే்Lj Steveڦ๚൧఼Ǜ߸ࡻڦࡗ฿߸ࡻڦ ටኸ؜ేڦอߡኁăሞิऄዐLj࣏ᆶ๊஺Բᆶኈኟٓ௽ڦဃٱჹዘܠ࢔ڦߌႇఫၵኸ؜࿢ Acknowledgments ዂႇ http://www. oreilly.com/ ኷ǖྪڦ୤࿢்ک႑တ൩ܠ߸ڦກढĂࣷᅱĂጨᇸዐ႐ࢅ O’Reilly ྪஏڦ࠲ᇀ࿢் bookquestions@oreilly.com සࡕేၙ৽Ԩກ݀՗ೠஃई༵࿚रຍ࿚༶Lj൩݀ໃ E-mail ዁ǖ http://www.oreilly.com/catalog/9780596517748 ࿚ǖ ኁ੗ٗසူྪ኷ݡ܁࿢்ॽྺԨກ༵ࠃዷᄻLjሞഄዐ༵ࠃਿဃ՗Ă๖૩तഄ໱޹े႑တă ӎટ૧रຍጧკDŽԛ৙Džᆶ၌ࠅິ ေ C ፗ 807 ๪DŽ100035Džٷন 2 ࡽׯఀٷԛ৙๨ဇ׭൶ဇ኱ோళ ዐࡔǖ Sebastopol , CA 95472 1005 Gravenstein Highway North O’Reilly Media, Inc. ெࡔǖ മჾ ϶!! xvii  Most Popular Programming LanguageDŽhttp://javascript.crockford.com/popular.htmlDžă କᅃೊ The World's Most Misunderstood Programming Language Has Become the World’s ሆ 3 න໱ᆼႀ 3 ڦLanguageDŽhttp://javascript.crockford.com/javascript.htmlDžăሞ 2008 ౎ ᅳጀ 2ǖ Ԩກፕኁሼႀࡗᅃೊ࿔ቤ JavaScript:The World's Most Misunderstood Programming tional.org/memento/TC39.htmă ఁጴăၘ൧९ http://www.ecma-interna-ڦरຍ྿ᇵࣷڦᅳጀ 1ǖ TC39 ๟ჺ৯ JavaScript ᇕჾ৊ࣅ  ᄺ৽ுᆶՂᄲକăDŽ ยऺኁLjுᆶ໱LjኄԨກڦ ᇕჾᅳጀ 2ײՊڦፌࢫLjႇႇ Brendan EichLjኄ࿋๘হฉፌԥဃ঴ अऺ்ăDŽڦECMA TC39 ᅳጀ 1 ዐ ڦᇕჾܸݺ۷ڦᅃோ߸ࡻ ໯ᆶ๚൧ăཞ้Lj࿢ᄲႇႇఫၵᅃ኱ྺ๑ ECMAScript ׯྺڦ༬՚ߌႇ Lisa Drake ঞ๲໯ፔ മჾ xviii!϶  2 1 Ă߸ᅟᇀྼࢺă܁ኝ༹Lj໲߸੗੍Ă߸ᅟڦᆫᇀኄோᇕჾںٷٷᆫჯጱणڦဦጟ؜ઠ ۓኈํԨዊጲ࿢၂୞؜ઠă࿢၎႑࿢৛ڦኄோᇕჾڟ༬Ⴀ኱ڦ૙็Lj࿢ᄲԊ஌ఫၵփࡻٷ ᇕჾă JavaScript ৽ၟᅃ੷ײༀՊۯڦ໲๟ᅃோম؜ڢኪॆٷ৛ࣀLjඟڦত๖ JavaScript ዐ ৽๟ᄲڦణڦ྘ਏăԨກڦĂுᆩڦ๟ǖ JavaScript ৽๟ᅃؙ߲୒ۅዷୁ࠵ڦ໲ܔ౎ઠܠᇀ ᆆ֠ጣLjᅜ዁ںևݴԥศศڦᇕჾ༬Ⴀ৽ၟᅃܑኆዩࢅᇉణंሗሞᅃഐă JavaScript ፌԨዊ ڦĂ޷ᆶ՗၄૰ڦĂᆫჯڦևݴăሞ JavaScript ዐLjெૢڦࡻሞ JavaScript ᆶᅃၵݥ׉৛ࣀ ᆖၚă ڦዊଉڦႜबࢭྜඇփ๴໲ୁڦ ᇕჾLj JavaScriptײĐWeb ᇕჾđăፕྺᅃோՊڦׯକఐණ ӨLj JavaScript Վ฿ڦႾDŽ Java™ appletsDžײၭᆌᆩڦ™Navigator 2 ៓બഗዐăໜጣ Java ڦৠྪڟ໲࣏ݥ׉้֢ٚLj໲৽ԥ኱থणׯړఉăٶ๴ă໲ٗઠுᆶሞํᄓ๪૛ԥ๬ᆩࢅ क़૛ԥඇ๘হ໯থ้ڦସට׺৚ڟ܌Lj৽ሞิڐ؜କᇨଙă໲ᅃגԲዘڦJavaScript ዐሧ೩ ႾăײڦఫևݴඁՊႀ߸ࡻڦጱणăేྜඇ੗ᅜएᇀ৛ࣀڦ๟LjͿᆶ඄૰ۨᅭేጲमڍ ሧ೩ăڦܠLjܸٗ੗ీׂิ؜߸ت࿮ీྺ૰ăܸ൐ႎ৹༬Ⴀժփጺ๟ీࢅၿࠌ ༬ႠLj໱்ཚ׉ڦܠඍ။ฉܑओ߸ܑٷᅃڦକሞᅙ٪ሞأႾăײڦḡগڦᅈડᇀఫၵሧ೩ Ljᅺྺኄᄣፔࣷ໦࡞໯ᆶڦඍ။ևݴLjኄबࢭ๟փ੗ీڦᅃோᇕჾዐأՔጚ྿ᇵࣷၙᄲᅎ ႾᇵăԹ৩Ljᆩ࣋֌ଙሹ஺ీፔ؜ࡻ۫ဇ఼Ǜײڦ߸ࡻ ࣆLj࿢੗ᅜׯྺᅃ߲ڦᆶ৛ࣀࢅሧ೩ă࿢݀၄සࡕൽഄ৛ࣀܸചഄሧ೩ۼᇕჾײຕՊܠٷ ăٱኁᄺࣷݖ ยऺڦဃăᆶ้ࢪᇕჾٱLj࣏ᆶᅃၵ༬Ⴀ৽๟ยऺٱඐᅟᇀ؜ڍ༬Ⴀᆻ๑࿢ጕ൱ആरᆁേ ईႪ߀Ljᅃၵ܁ஓవᅜለپዂڞዂ੗ᅎኲႠ࿚༶Ljᅃၵ༬Ⴀࣷڞᅺྺࡀݔ࢔փྜ฀ܸ੗ీ ॏኵăഄዐLjᅃၵ༬Ⴀڦ؜໲்ג஑ݑᇺᇺڦઠټፌዕLj࿢ණۨኄၵ༬Ⴀዐᆶᅃևݴ༬Ⴀ ăٴ঴ీۼ༬ႠକසኸቨLjຣᆶ࿚༶࿢ ߲߳ܔཀྵLjᅺྺ࿢ޅඓ؜କփณڦࡻݛ݆Ljܸ࿢ᄺڦ༬Ⴀă࿢ණྺኄ๟᫙ᄳڦ๬๑ᆩ໯ᆶ Ⴞ้ࣷ׈ײ௅߲༬Ⴀă࿢ႀڦႾᇵ้Lj࿢ၙቨ࿥ጲम໯ᆩᇕჾײڦ؜யୖ؛࿢࣏๟ᅃ߲ړ ౓்ܹėDŽThe Merry Wives of WindsorDžୁޅڦĊĊྰ૸Ą෩๗ԲჱLjĖ࿒෩ ఋ૰ǛڦݛܸᅙLjሹ஺ࣷᆶ๊஺௚ටںڦčč࿢փࡗ୼ᆶᅃၵ༪ටဠ࣌ Good Parts ৛ࣀ ቤ 1 ڼ 1   3 ăڪ ᅳጀ 2ǖ ጆኸᅃၵዷୁᇕჾLjၟ CĂC++ĂJavaĂPerlĂPython ณੁ݃ᅃၵຏఢă ኽቧณକLj৽੗ᅜڦӁ๖ኄԨກኻ࠲ጀ৛ࣀևݴLj໯ᅜກՎԋକLjᆩںᅳጀ 1ǖ ፕኁኄ૛ᆪఐ  ఇ႙ăײՊڦԈઔएᇀඇਆՎଉ݆ၙڦߞ ၡጴ௬ଉ՗๖݆ăఫၵሧܔڦၡࢅ޷ᆶ՗၄૰ܔༀۯԈઔࡧຕĂෑૌ႙Ă݆ၙڦఫၵᆫႯ ኮฉă݆ၙڦࢅณຕݥ׉ሧߞ݆ၙڦJavaScript ॺ૬ሞᅃၵݥ׉ᆫႯ Analyzing JavaScript ݴဆ JavaScript ߾ፕăڦጒༀူਸ๔ేڦۮۮ๚൧ăਨփᆌ޿ሞឈឈڦ๟࢔ઓవײ߸ࡻăՊڥ໲࣏ీ՗၄ ᄲፔ๊஺้Ljڢኪేړᇕჾăڦ૰ీٳ઄ူLjేᄺీᆩ໲ઠྜׯ߾ፕă໲๟ᅃோᆛᆶटഽ՗ ൧ڦକ঴ܠுᆶ໿ۼײՊܔକ঴Ljฯ዁ܠኄோᇕჾுᆶ໿ܔ๚൧๟LjሞڦJavaScript ସට৚ᅴ ཞLjܸ൐ኄၵփཞ዁ྺ࠲॰ă փٷዷୁᇕჾᆶ࢔ڦ၄Lj JavaScript ߶໱்ౢᇼ๑ᆩ݀ں঳ࡕ໱்ࣷ৚ჲڍბࡻ JavaScriptLj ுՂᄲံඁڥຕටਥܠٷăሞኄዖ൧ႚူLjڦସටᄋݑړඓ๟၎ڦ ఫ஺ԥ೨๑ᆩ JavaScript Ljײ࣍ৣዐՊڦ ඐሞᅃ߲ኻኧ׼ JavaScriptڍ ᅳጀ 2ăසࡕే෽׊గၵዷୁᇕჾLj LANGUAGEDžDŽ ዷୁᇕჾDŽ SOME OTHERڦᇕჾLjᅺྺ໲փ๟໯࿍ڦJavaScript ๟ፌԥൟ๫ ඪခăڦກ৽ၟኴႜᅃၜփ੗ీྜׯڦ৛ࣀڦ DOMLj࿢ණྺႀᅃԨ࠲ᇀ DOM ࢔ጜଝժ൐ํ၄ࢻփᅃዂăԨກ࢔ณภतڥࡀݔ዆ۨڦ๚൧Lj໲ڦ๟ᅃॲས੮ۼ ૙ DOM تኸሴăሞඪࢆᇕჾዐڦփࠅೝڟሧߞLj૶ે JavaScript ሦړၡఇ႙DŽ DOMDž၎ܔڗࢅ࿔ API ڦᇕჾኮᅃă៓બഗײՊڦᇕჾኮᅃăཞ้Lj໲ᄺ๟๘হฉፌԥൟ๫ײՊڦহฉፌୁႜ ঳ࢇ๑໲ׯྺ๘ڦᇕჾă໲ᇑ៓બഗڦᇕჾLjᅺྺ໲๟ Web ៓બഗڦJavaScript ๟ᅃோዘᄲ Why JavaScript? ྺ๊஺ᄲ๑ᆩ JavaScript ߾ፕăںᇵ߸ࡻ JavaScript ጱण๟ྺକඟጆᄽට ڦሞኄ૛Lj࿢዆ۨڍბသăںጱण๟ྺକඟბิ߸ࡻڦᇕჾ ăᆶ้ࢪLj዆ۨܔࣷ࢔փᇼᅪ௬ۼຕටܠٷڦ߾ፕLj࿢்ዐڦăኄ๟ᅃ߲ݥ׉ས੮ڦઓవ ఇ๕๟ݥ׉ڦ৽๟ే੗ᅜփՂཀྵསසࢆྮऻሧ೩ăྮۖփࡻتࡻٷፌڦईႹLjኻბသ৛ࣀ ᅳጀ 1ă ბသ้क़Ljሺഽॳ጑ႠLjժ൐࣏ీኞ৸ᅃၵຏఢDŽ܌ጀᇀ৛ࣀևݴLj࿢்৽੗ᅜ໫ ၭăཚࡗৈጆٷႾLj࿮ஃࡀఇײڦ܁Ăᅟڦጱण੗ᅜᆩઠࠓሰ੗੍ڦ೩ևݴăኄ૛ॽԥ௮ຎ ໙ඇ௬௮ຎኄோᇕჾăݒኮLj໲ॽጆጀሞ৛ࣀևݴLjཞ้ࣷ౾ܻয়ߢᄲඁՆ௨ሧٶኄԨກփ ቤǖ৛ࣀ 2 1 ڼ!϶  http:// json.org/json-zh.htmlă ૬ኁă࠳ݛྪበዐ࿔Ӳྪ኷๟ظڦᅳጀ 7ǖ Ԩກፕኁᄺ๟ JSONDŽJavaScript Object NotationDž http://zh.wikipedia.org/wiki/Schemeă ဦాඹ൩९ၘܠݛჾኮᅃă߸ڦᇕჾLj໲๟ଇዖ Lisp ዷᄲײՊڦݔ႙ܠᅳጀ 6ǖ SchemeLjᅃዖ ဦాඹ൩֖९ http://zh.wikipedia.org/wiki/Lispăၘܠᇕჾă߸ײࡧຕ๕Պڦᅃዖएᇀ ᄇ໙ ڦሰظ૙ᇕჾDžLj๟ᆯሀࡪĄ஛ਸ਼ဍሞ 1960 ౎ፑᆸتᅳጀ 5ǖ LispDŽඇఁ LISt ProcessorLjन૾՗ http://zh.wikipedia.org/wiki/ ᄇ໙ă ဦాඹ൩֖९ၘܠᆖၚLjԲස Lisp ᇕჾĂML ᇕჾࢅ Haskell ᇕჾă߸ڦٷᆶ਎ ײࡧຕ๕Պܔႚ๕ဣཥă໲ڦࡃڿᅳጀ 4ǖ Lambda ᄇ໙๟ᅃ༫ᆩᇀჺ৯ࡧຕۨᅭĂࡧຕᆌᆩࢅ Ӳ၎࠲ቤবĊĊĐ8.8.1 َ݆ፕᆩᇘđă 5 ڼ֖९ĖJavaScript ඄ྰኸళėዐᅳ ăਏ༹ాඹڦༀࣄݴፕᆩᇘۯLjܸփ๟ڦࡧຕ๟ߵ਍َ݆ઠࣄݴፕᆩᇘڦᅳጀ 3ǖ JavaScript ዐ  ๑ᆩںևݴԥጺ঳ሞ޹୤ B ዐăසࡕేၙბသఫၵሧ೩Ljᅜतසࢆጜଝٷڦሧ೩Lj໲்ዐ ຕܠٷڦڟՆ௨Ԩກዐ༵ں๟࿢்ॽׯࠀڍࣷॽ໲்ኸ؜ઠă໲்ᄺԥጺ঳ሞ޹୤ A ዐă ภतኄၵևݴ้Lj࿢ړୀవᅜՆ௨Lj۾ሞగၵ൧઄ူLj࿢்੗ీ࿮݆ࢮ୼ሧ೩Lj࣏ᆶᅃၵ ૙ݛ݆ăتڦJavaScript ᄺߴ࿢்༵ࠃକ࣐঴ኄ߲࿚༶ Ljڟă႞ࡻLj࿢்থူઠࣷੂإ໲்ሞ JavaScript ዐඐ๟एڍ൧LjᅺྺඇਆՎଉ๟ఋࡇLj ๚ڦࠅࠌంఁ੣क़ዐăኄ๟ᅃॲሧߞڦၡDŽ the global objectDžܔᅃ߲ԥ׬ྺඇਆڟࢇ٭ଉԥ पՎۥ໯ᆶڦᇮڇሧߞǖ JavaScript ᅈડᇀඇਆՎଉઠ৊ႜ૶থă໯ᆶՊᅳړᆶᅃ߲჋ስ၎ ๟ڍăڦຕ൧઄ူLjኄၵ჋ስ๟ࢇ๢ܠٷ჋ስฉԏ๴ݥᅱă໚඗ሞڦJavaScript ሞ࠲॰າၙ ౮૰ॽࣷᆶ໯࣮Ԓăڦᇱ႙Ljే ๑ᆩ JavaScriptں๟Ljසࡕేბࣷକጲසڍยऺఇ๕Ljేॽࣷሦ๴ٰችăڦ኱থᆌᆩएᇀૌ JavaScript ܔ߁౒ăසࡕే׈๬ڦႾᇵ்ઠຫLjᇱ႙ी׶๟ᅃ߲ఔิײڦၡܔॺظ๑ᆩૌඁ ఫၵԥჟଁܔ๟ڍLjٷ࢔ഽڦၡी׶ຌႠăኄኈܔၡ኱থٗഄ໱ܔဣཥLjሞኄ߲ဣཥዐLj ၡܔDŽ class-freeDžڦ༬Ⴀă JavaScript ᆶᅃ߲࿮ૌ႙ڦᇱ႙ी׶๟ JavaScript ዐᅃ߲ᆶኛᅱ ඹăDžాڦ ࠲ᇀ JSONܠ୤ E ዐॽࣷᆶ߸ ᅳጀ 7ăDŽ޹ ຕ਍঍࣑߭๕ DŽڦଳߌઠᇸLj ໲၄ሞᅙঢ়ׯྺୁႜڦ ॺ؜ઠă ኄዖ՗๖݆๟ JSONظ ԥںڇፇׯևݴLj໲்৽ీ०ڦၡܔၡጴ௬ଉ՗๖݆ăཚࡗଚ؜ܔڦٷJavaScript ᆶݥ׉ഽ ႜྺăڦᄲၙڟڥૌْ֫Lj࿢ᆦᇺփᆩፔഽ዆ሰ႙Ljᄺփᆩೃᇀᆌ޲ૌ႙ဣཥᅜڦްሗ ă࿢࿮Ⴗॺ૬ڦဃăଷᅃݛ௬Lj࿢݀၄ෑૌ႙๟ጲᆯٱڦဃժփ๟ସ࿢ཀྵསٱڦڟ႙ॠֱቴ ൟ຿ăܸ൐࿢ሞ߾ፕዐ݀၄Ljഽૌڥ๬߾ፕՎ֪ڦ๚ํኤ௽Ljഽૌ႙ժփࣷඟేڍ੤ࣛăڟ ਸ݀ටᇵߌڦ ဃăኄ੗ీඟٗഽૌ႙ᇕჾገၠ JavaScriptٱJavaScript Պᅳഗփీॠ֪؜ૌ႙ ᇕჾLj໯ᅜڦॏ৽ሁၭă JavaScript ๟ᅃோෑૌ႙پڦဃLj޲؜ٱ࿢்ీሁራॠ֪ࢅႪް ဃăٱႜᄲ൱ഽૌ႙ăഄᇱ૙ሞᇀഽૌ႙ሎႹՊᅳഗሞՊᅳ้ॠ֪ୁۼᇕჾዐײևݴՊٷ၄ৃ ᇕჾăڦٷഽ JavaScript ׯྺᅃ߲ݥ׉ ڥLispăኄ๑ ڦă໲๟ಽጣ C ྔᅊۅࠌཞڦܠᅳጀ 6 ᆶ߸ ࢅ SchemeDŽ ᅳጀ 5 ᇀ Java ܸჾLj JavaScript ᇑ LispDŽܔᅳጀ 4 ᇕჾăํाฉLj၎ LambdaDŽ ڦᅃ߲ׯྺዷୁڼ๟ ၡă JavaScriptܔपۥڦ ᅳጀ 3 ࡧຕ๟DŽዷᄲDžएᇀَ݆ፕᆩᇘDŽ lexical scopingDžDŽڦ JavaScript ݴဆ JavaScript!!! 3  4 ቤ঴๥໲ă 4 ڼ࿢ࣷሞ }; return this; this.prototype[name] = func; Function.prototype.method = function (name, func) { ᅭǖۨڦݛ݆ඁۨᅭႎݛ݆ăူ௬๟໲ ᅃ߲ methodڟࣷᆩۼ๔ዕןHTML ࿔ॲֱੂ঳ࡕă Ԩກ࠻ ڦਸేٶબഗ៓ڦူᅃօLj ᆩే document.writeln('Hello, world!'); ॺᅃ߲গԨ࿔ॲLjԲසഐఁྺ program.jsǖظথူઠLjሞཞᅃ߲࿔ॲॄాLj