2013年新卒研修 JavaScript基礎

2013年新卒研修 JavaScript基礎

B16717ef4b7aab0b253d933c3934f280?s=128

mixi_engineers

September 13, 2013
Tweet

Transcript

  1. 9.

    +4Ͱͭ͘ΕΔ΋ͷ w࢖͍΍͍͢6*ɺ͔͍͍ͬ͜6* wϒϥ΢βήʔϜ wJ04 "OESPJEͷωΠςΟϒΞϓϦ ʢ5JUBJOVNͳͲϑϨʔϜϫʔΫΛར༻ʣ wࠓޙग़Δ'JSFGPY04΍5BJ[FOͷω ΠςΟϒΞϓϦʢϑϨʔϜϫʔΫͳ͠ Ͱʣ w8JOEPXT̔ΞϓϦ

    wαʔόʔαΠυϓϩάϥϛϯά ʢωοτϫʔΫϓϩάϥϛϯάɺϑΝ ΠϧॲཧͳͲʣ wνϟοτͳͲϦΞϧλΠϜੑͷߴ ͍8FCΞϓϦ ΫϥΠΞϯταΠυ+4 ϒϥ΢β֦ு αʔόʔαΠυ+4 ʢ/PEFKTͳͲʣ ωΠςΟϒΞϓϦ 
  2. 13.

    ߋ৽ੑ 69 ྑ ѱ ߴ ௿ ΢Σϒ wωΠςΟϒͷ"1*ʹ௚઀ΞΫηεͰ͖ΔͷͰ ࣗ༝౓͕ߴ͍ w୺຤ʹΠϯετʔϧ͢ΔͷͰɺωοτϫʔΫ

    ܦ༝ͰಡΈࠐΉ΋ͷ͕গͳ͘ɺىಈ͕ૣ͍ ʢΞϓϦʹΑͬͯ͸ΦϑϥΠϯͰ΋࢖͑Δʣ w৹͕ࠪ͋ΔͨΊ͙͢ʹϦϦʔεͰ͖ͳ͍ʢJ04ʣ wϢʔβʔ͕ΞϓϦΛΞοϓσʔτ͢Δͱ͸ ݶΒͳ͍ ˠόάΛमਖ਼ͯ͠΋͙͢ʹϢʔβʹಧ͚ΒΕͳ͍ ˠࡉ͔͍ݕূͱվળ͕ͮ͠Β͍ wϚϧνϓϥοτϑΥʔϜରԠͷίετ͕ߴ͍ ωΠςΟϒ ΞϓϦ 
  3. 14.

    ߋ৽ੑ 69 ྑ ѱ ߴ ௿ ωΠςΟϒ w৹ࠪ͸ͳ͍ͷͰ͙͢ʹϦϦʔεͰ͖Δ wϢʔβ͕Πϯετʔϧ͠ͳͯ͘΋࠷৽൛͕ ൓ө͞ΕΔ

    wϚϧνϓϥοτϑΥʔϜରԠ͕༰қ wωΠςΟϒͷ"1*ʹ௚઀ΞΫηεͰ͖ͳ͍ ͷͰɺࣗ༝౓͕௿͍ w)5.- $44 +4 ը૾ͳͲຖճଟ͘ͷϑ ΝΠϧΛϩʔυ͢ΔͷͰىಈ͕஗͍ ΢Σϒ ΞϓϦ 
  4. 15.
  5. 16.

    8FCͷ69ΛΑΓྑ͘͢ΔͨΊͷٕज़ w%FWJDF"1*͂ w .FEJB$BQUVSF"1*ʢΧϝϥ΍ϚΠΫʹΞΫηεʣ w $POUBDUT"1*ʢి࿩ாʹΞΫηεʣ wΦϑϥΠϯΞϓϦέʔγϣϯ w "QQMJDBUJPO$BDIF w

    /FUXPSL*OGPSNBUJPO"1* ʴϋʔυ΢ΣΞεϖοΫͷ޲্ɺ௨৴଎౓ͷ޲্ ʲࢀߟʳ೥ʹ͸ 8FCΞϓϦͷʮΦϑ ϥΠϯϑΝʔετʯ ͕ྲྀߦ͢ΔͷͰ͸ͳ ͍͔ʁʵ1VCMJDLFZ 
  6. 18.

    w࢖͍΍͍͢6*ɺ͔͍͍ͬ͜6* wϒϥ΢βήʔϜ wJ04 "OESPJEͷωΠςΟϒΞϓϦ ʢ5JUBJOVNͳͲϑϨʔϜϫʔΫΛར༻ʣ wࠓޙग़Δ'JSFGPY04΍5BJ[FOͷω ΠςΟϒΞϓϦʢϑϨʔϜϫʔΫͳ͠ Ͱʣ w8JOEPXT̔ΞϓϦ wαʔόʔαΠυϓϩάϥϛϯά

    ʢωοτϫʔΫϓϩάϥϛϯάɺϑΝ ΠϧॲཧͳͲʣ wνϟοτͳͲϦΞϧλΠϜੑͷߴ ͍8FCΞϓϦ ΫϥΠΞϯταΠυ+4 ϒϥ΢β֦ு αʔόʔαΠυ+4 ʢ/PEFKTͳͲʣ ωΠςΟϒΞϓϦ ຊݚमͰ͸ΫϥΠΞϯταΠυ+4Λѻ͍·͢ 
  7. 19.

    w पғͷਓͷαϙʔτ w ࣗಈͰKTIJOU͕࣮ߦ͞ΕΔ؀ڥΛ੔උ WJNTZOUBTUJD KTIJOUWJN FNBDTKTIJOUNPEF qZNBLFOPEFKTIJOU w CSPPLKT΍/BNFTQBDFKTͷֶश

    IUUQTHJUIVCDPNIJSPLJEBJDIJOBNFTQBDFKT IUUQTHJUIVCDPNIJSPLJEBJDIJCSPPL w "QQMJDBUJPO$BDIFͳͲ8FCͷ69ΛΑΓྑ͘ ͢ΔͨΊͷٕज़Λௐࠪ +4Ϛελʔͷਓ΍՝୊͕ૣ͘ऴΘͬͨਓ͸ ࣍ͷ͜ͱʹऔΓ૊ΜͰ͍ͩ͘͞ 
  8. 22.

    +BWB4DSJQUͷ࢖༻ํ๏  )5.-λάʹ௚઀ຒΊࠐΉ  TDSJQUλάΛར༻͢Δ  ֎෦ϑΝΠϧΛಡΈࠐΉ <script  type=“text/javascript”  src=“helloworld.js”>

    </scirpt> <script  type=“text/javascript”>alert(‘hello’);</scirpt> <a  href=”javascript:alert(‘hello’);”>hello</a> 
  9. 27.

    func%on'test'()'{' '''''var'message'='"a";' '''''if'(1)'{' '''''''''var'message'='"b";' '''''''''print('if_scope'<>'''+'message');' '''''}'' '''''print("test_func'<>'"'+'message);' '}' '' 'test();

    sub'test'{' '''''my'$message'='"a";' '''''if'(1)'{' '''''''''my'$message'='"b";' '''''''''print'"if_scope'<>'".$message."\n";' '''''}' '''''print'"test_scope'<>'".$message."\n";' '}' ''' 'test; Perl JS if_scope  -­‐>  b test_scope  -­‐>  a if_scope  -­‐>  b test_scope  -­‐>  b 
  10. 32.

    %0.πϦʔ <UL> <LI> HogeHogeHoge <LI> <LI> HugaHugaHuga MogeMogeMoge  

       <ul>    <li>HogeHogeHoge</li>    <li>HugaHugaHuga</li>    <li>MogeMogeMoge</li> </ul> ̍ͭ̍ͭͷཁૉΛϊʔυͱ͍͍·͢ 
  11. 33.

    ϊʔυͷؔ܎ <LI> <LI> <LI> previousSibiling nextSibiling <UL> <UL> <UL> <DIV>

    parentNode    firstChild childNodes [0] [1] [2] lastChild 
  12. 34.

    %0.ૢ࡞ͷͨΊͷؔ਺ w HFU&MFNFOU#Z*E lJEz w HFU&MFNFOUT#Z$MBTT/BNF lDMBTT/BNFz  w HFU&MFNFOUT#Z5BH/BNF

    lUBH/BNFz w RVFSZ4FMFDUPS lDTTTFMFDUPSTz w RVFSZ4FMFDUPS"MM lDTTTFMFDUPSTz ˞RVFSZ4FMFDUPS͸ɺ*&Ҏલ͸ඇରԠ 
  13. 39.

    ԋशʢ͢΂ͯ1$൛NJYJʣ  ্ʹฒΜͰ͍ΔϝχϡʔϘλϯʢϓϩϑΟʔϧɺ ༑ਓϦετɺͭͿ΍͖ɾɾɾʣͷ͏ͪͲΕ͔̍ͭ Λඇදࣔʹ͍ͯͩ͘͠͞ ώϯτɿIJEF ͰඇදࣔʹͰ͖·͢  ࠨӈͷΧϥϜΛ൒ಁ໌ʹ͍ͯͩ͘͠͞ʢߦͰʣ ώϯτɿΧϯϚ۠੾ΓͰෳ਺ͷηϨΫλΛࢦఆͰ͖·͢

    ɹɹɹɹDTTͷPQBDJUZଐੑͰෆಁ໌౓ΛࢦఆͰ͖·͢  ϑΟʔυʹදࣔ͞Ε͍ͯΔ༑ਓશһͷχοΫωʔ Ϝͷ຤ඌʹɺ Λ͚͍ͭͯͩ͘͞ ώϯτɿVOEFSTDPSFͷFBDI Λ࢖͍·͠ΐ͏ˠϦϑΝϨϯε 
  14. 48.

    BEE&WFOU-JTUFOFS WBSBEPDVNFOUHFU&MFNFOU#Z*E lUFTUz  BBEE&WFOU-JTUFOFS lDMJDLz GVODUJPO F \ BMFSU

    lIPHFz  ^ GBMTF  BEE&WFOU-JTUFOFS UZQF FWFOU-JTUFOFS VTF$BQUVSF  
  15. 49.

    Πϕϯτͷ఻೻ <UL> <LI> HogeHogeHoge <LI> <LI> HugaHugaHuga MogeMogeMoge ൃՐ ᶄόϒϦϯά

    ᶃΩϟϓνϟϦϯά EPDVNFOU ΦϒδΣΫτ υΩϡϝϯτͷ ϧʔτϊʔυ 
  16. 50.

    <UL> <LI> HogeHogeHoge <LI> <LI> HugaHugaHuga MogeMogeMoge EPDVNFOU ΦϒδΣΫτ ֤MJʹผʑʹΠϕϯτϦ

    εφʔΛొ࿥͢ΔͷͰ͸ͳ ͘ɺ্ҐͷVMͻͱͭʹొ ࿥͢Ε͹0, EFMFHBUFʢҕৡʣ υΩϡϝϯτͷ ϧʔτϊʔυ ΠϕϯτϦεφʔ ΠϕϯτϦεφʔ ΠϕϯτϦεφʔ ΠϕϯτϦεφʔ 
  17. 51.

    ՝୊ w ؆қΠΠωϘλϯΛͭͬͯ͘Έ·͠ΐ͏ w Ϙλϯ͕ԡ͞ΕͨΒݟͨ໨Λม͍͑ͯͩ͘͞ w ༨༟͕͋Ε͹ෳ਺ͷϘλϯʹ̍ͭͷΠϕϯτϦεφʔͰର Ԡ͍ͯͩ͘͠͞ʢK2VFSZͷPO ͰEFMFHBUFͯͩ͘͠͞ ͍ʣ

    w ౤ߘϑΥʔϜʹจࣈ͕ೖྗ͞ΕΔͨͼʹจࣈΧ΢ϯτ Λߋ৽͍ͯͩ͘͠͞ ˞͖ͭͮʢͭͿ΍͘ϘλϯΛԡͨ͠ΒϑΟʔυ͕දࣔ͞ΕΔͳͲʣ ɹ͸࠷ޙͷ՝୊Ͱ΍Γ·͢ 
  18. 55.

    ؔ਺એݴจ BEE)PHF lCFGPSFz lCFGPSF)PHFz GVODUJPOBEE)PHF TUS \ SFUVSOTUS l)PHFz ^

    BEE)PHF lBGUFSz lBGUFS)PHFz w ؔ਺એݴจ͸ר্͖͛ΒΕΔͷͰɺؔ਺એݴจΑΓ্Ͱݺͼ ग़ͯ͠΋ਖ਼࣮͘͠ߦ͞Ε·͢ 
  19. 57.

    ؔ਺Ϧςϥϧࣜ WBSBSSBZ<> BSSBZQVTI BEE'VHB  BSSBZ<> lUFTUz  UFTU'VHB WBSPCK\^

    PCKBEE'VHBBEE'VHB PCKBEE'VHB lUFTUz  UFTU'VHB ഑ྻ ΦϒδΣΫτ w ؔ਺Λ഑ྻʹ௥ՃͰ͖·͢ w ؔ਺ΛΦϒδΣΫτͷϓϩύςΟʹઃఆͰ͖·͢ 
  20. 58.

    ؔ਺ΛҾ਺ʹͱΔؔ਺ K lCVUUPOz PO lDMJDLz GVODUJPO \ BMFSU lDMJDLFEz 

    ^  w ͜ͷΑ͏ʹɺ໊લͷແ͍ؔ਺Λແ໊ؔ਺΍ಗ໊ؔ਺ͱ͍͍·͢ w ࣄલʹొ࿥͓͖ͯ͠ɺඞཁʹԠͯ͋͡ͱ͔Βݺͼग़͞ΕΔؔ਺ ΛίʔϧόοΫؔ਺ͱ͍͍·͢ 
  21. 59.

    ؔ਺Λฦؔ͢਺ WBSDSFBUF"EE4US'VODGVODUJPO TV⒏Y \ SFUVSOGVODUJPO TUS \ SFUVSOTUS TV⒏Y ^

    ^ WBSBEE)PHFDSFBUF"EE4US'VOD l)PHFz  WBSBEE'VHBDSFBUF"EE4US'VOD l'VHBz  BEE)PHF lUFTUz UFTU)PHF BEE'VHB lUFTUz UFTU'VHB 
  22. 60.

    Ϋϩʔδϟ WBSDSFBUF"EE)PHF8JUI$PVOUGVODUJPO \ WBSDPVOU SFUVSOGVODUJPO TUS \ DPVOU  SFUVSOTUS

    l)PHFz DPVOU ^ ^ WBSBEE)PHFDSFBUF"EE)PHF8JUI$PVOU  BEE)PHF lUFTUz UFTU)PHF BEE)PHF lUFTUz UFTU)PHF  ࣗ෼ͷ֎ଆʹ͋Δ ม਺Λࢀর
  23. 61.

    ଈ࣌ؔ਺ʢม਺ͷείʔϓʣ GVODUJPO \ WBSBlBBBz DPOTPMFMPH B BBB ^  DPOTPMFMPH

    B VOEFpOFE w ؔ਺Λఆٛͯ͠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