Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
安全なJavaScriptを書く
Search
Kohei Asai
December 15, 2015
Programming
8.7k
22
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
安全なJavaScriptを書く
SCRIPTY #4 on 2015-12-15
Kohei Asai
December 15, 2015
More Decks by Kohei Asai
See All by Kohei Asai
The State Transparented Web Application
axross
1
350
UIコンポーネント指向と「協働」
axross
6
2.9k
Introduction to Redux
axross
34
22k
作るのにデザイナーもエンジニアもない
axross
14
7.3k
なぜprottか
axross
4
2.7k
コンポーネント指向による、Reactのベストプラクティスとバッドプラクティス
axross
0
460
Nodeとフロントエンド − 知っておかなければならない、今と未来の話 −
axross
2
1.4k
gulpを使うと彼女ができるよ - かんたんな紹介とハンズオン
axross
2
1.1k
Other Decks in Programming
See All in Programming
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
360
Java 27新機能 / Java 27 new features
kishida
2
140
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
330
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
110
FreeBSDでZabbixを動かす.pdf
kenkino
0
280
Family mrubyの進捗
kishima
1
120
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
170
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
190
Security issues being discussed on Web Platforms
petamoriken
0
940
From 6 People Classroom Meetup to 100 People Regional Conference / FOSS4G Hiroshima 2026
furukawayasuto
0
200
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
570
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
700
Designing for humans not robots
tammielis
254
26k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
240
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Building AI with AI
inesmontani
PRO
1
1.2k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
520
Making the Leap to Tech Lead
cromwellryan
135
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
480
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
Transcript
҆શͳJavaScriptΛॻ͘ @axross SCRIPTY #4 on 2015-12-15
whoami » @axross / Kohei Asai » Gunosy Inc. »
ωτήഇਓ -> հޢۀք -> Webۀք » SPAॻ͍͓ͯۚΒͬͯ·͢
ͨΓલͳ͜ͱΛ͠· ͢
ʮྫ֎ʯ
ྫ֎ʹର͢Δೝࣝ » Errorͷ͜ͱ » ྫ֎͕εϩʔ͞Εɺcatch͞Εͯͳ͍߹ɺ࣮ߦ͕ࢭ·Δ » ϓϩμΫγϣϯͰ࣮ߦ͕ࢭ·Δͱக໋త » ʮۃྗΤϥʔϋϯυϦϯά͠Α͏ʂʯͬͯؾ࣋ͪʹͳΔ͕...ʁ
None
27. ʮࢮ͵ͣͷϓϩάϥϜΛແཧʹ ੜ͔͓͍͍͚ͯͯ͠ͳ͍ʯ try-catch ϒϩοΫΛίʔυϕʔεʹେྔʹೖΕΕɺʮྫ֎͕ൃੜͯ͠ ઈରʹࢭ·Βͳ͍ʯͱ͍͏ΞϓϦέʔγϣϯΛ࡞Δ͜ͱ͕Մೳͳͣ Ͱ͢ɻ ͨͩɺ͜Εɺ͏ࢮΜͰ͍ΔਓͷମΛఝ͔Կ͔Ͱݻఆ͠ɺແཧཧ ཱͬͨঢ়ଶʹ͍ͯ͠ΔΑ͏ͳͷͰ͕͢......ɻ --
ΦϥΠϦʔɾδϟύϯʮϓϩάϥϚ͕Δ͖97ͷ͜ͱʯ
ແཧΓੜ͔͞ΕͨϓϩάϥϜ » ϓϩμΫγϣϯͰྫ֎͕throw͞ΕͯͳΒͳ͍ » ͳͥͳΒɺϓϩάϥϜͷ࣮ߦ͕ࢭ·ͬͯ͠·͏͔Β » Ͱɺͦͷྫ֎ԿʹΑΔͷͳͷ͔ʁ » ڥɾঢ়گʹΑͬͯൃੜͨ͠ͷʁ(HTTPݻ༗όάͳͲ) »
୯७ͳ։ൃऀͷϛεʹΑΔͷʁ » ͜ͷྫ֎ΛcatchͰ௵͢ͷϚζ͍Μ͡Όͳ͍ͩΖ͏͔ʁ
ߟ͑Δ͖͜ͱ » ਖ਼ৗͳಈ࡞Ͳ͏͍͏ܗͳͷ͔ʁ » ͕ؔҙਤ͠ͳ͍ҾΛͬͯݺΕͨΒʁ » ͜͜Λ༨ܭͳ͓ੈͰʹʮແࢹ͢Δʯͱ͔ͯ͠͠·͏ͱɺ։ൃ ऀͷਓతͳϛεڐ͢Մೳੑ͕͋Δ » ʮ͜͏͍͏έʔε͋Δ͔͠Εͳ͍ʯͱ͍͏ରԠΑ͘ͳ͍
» ʮ͍͚͋ͬͯͳ͍ɺ͔ͩΒྫ֎ͩʯ » ͜Ε͕ྫ֎ͷਖ਼͍͠ΘΕํͩͱࢥ͏
ʮؾ͔ͳ͍ʯํ͕ා͍ » ༏͗͢͠ΔAPI࡞Βͳ͍ » ʮArray͡Όͳͯ͘ड͚͚Δ෮ॲཧͷؔʯΛͲ͏ࢥ͏͔ʁ » νʔϜͰೝ͕ࣝ߹ͬͯΕ͍͍ » ͔͠͠ɺόάʹʮؾ͚ͳ͘ͳΔʯͷશʹବ »
σόοάςετόάΛݕग़͢ΔͨΊʹ͋Δ » ݕग़Ͱ͖ͳ͘ͳͬͯ͠·ͬͨΒɺͦΕʮ༏͍͠ʯͩΖ͏͔ʁ
Ͳ͏ͨ͠Β͍͍͔
throwΛා͕Γ͗͢ͳ͍ » throw͖͢ͷͪΌΜͱ͠Α͏ » ։ൃதʹྫ֎Λ౿ΊΕɺݕग़ͮ͠Β͍όάΛ༧ͨ͜͠ͱʹͳ Δ » ʮਖ਼ৗಈ࡞ͳΒى͜Δͣͷͳ͍throwʯා͕Γա͗ͳ͍͍ͯ͘ Α͏ͳʁ »
ແɺͪΌΜͱσόοάஈ֊Ͱݕग़͓ͯ͘͠ » Ϗδωεతͳສ͕Ұʹඋ͑ͯɺϦΧόϦʔͰ͖ΔΑ͏ʹ࡞Δ
assert / unassert » twada/unassert » ίʔυதͷassert()console.assert()Λআ͢Δͷ » throwͷΘΓʹassert()ΛͬͯɺAssertionErrorΛ͛Δ »
assert()ͳͲͷ෦͚͕ͩunassertʹΑͬͯআ͞ΕɺϓϩμΫ γϣϯ࣌ʹAssertionError͕ൃੜ͠ͳ͘ͳΔ » http://www.slideshare.net/t_wada/unassert
ΤϥʔΛऩू͢Δ » window.onerrorͰ΄΅શͯͷྫ֎ΛcatchͰ͖Δ » catchͨ͠ͷΛΤϥʔऩूαʔϏεʹ͛Δ » Sentry » Airbrake »
sourcemaps͕͋ΕಡԽޙͷίʔυղऍͯ͘͠ΕΔ » ͋Δ͍ɺGoogle AnalyticsʹஷΊΔ » ྫ֎Λऩूͯ͠ɺঢ়گݻ༗ݻ༗ͷόάΛݕग़͠Α͏
Lint͢Δ » eslintɺjshintɺjslint » ίʔυͷόουϓϥΫςΟεγϯλοΫεΤϥʔΛݕͯ͠ڭ͑ ͯ͘ΕΔ » ελϯεΛܾΊͯɺݫ͠Ίʹઃఆ͢Δɺ͖ͦͯͪ͠ΜͱकΔ » ਓతͳϛεΛ͍͘Β͔ݮͰ͖Δ
» ؇ΊΔͷةݥɺ؇ΊΔ߹͖ͪΜͱ͠߹͏ » ઃఆϑΝΠϧΛॻ͘͜ͱͰɺֶͼ͋Δ͔ʁ
ςετΛॻ͘ » ྫ֎ɺςετΛॻ͍ͯ։ൃதʹ͖ͪΜͱग़ձ͓ͬͯ͘ » ςετ͕େมͩͱײͨ͡ΒɺͦΕਓతϛε͕ى͖͍͢ͱ͍͏αΠ ϯ » ޙʑʹόάͷݪҼΛḷΔ͍͍ಓඪʹͳΔ » αϘͬͪΌବ!
ίʔυϨϏϡʔ͢Δ » Lintͯ͠ɺςετΛॻ͍ͯɺϛεΛ͢Δ͜ͱ͋Δ » ਓతͳϛεΛݟ͚ͭΒΕΔۀϑϩʔΛ͖ͪΜͱ࡞Ζ͏ » ϛεΛؾܰʹࢦఠͰ͖Δۭؾ࡞ΓΛ͠Α͏ » ϨϏϡʔͯ͠ίʔυΛڞ༗͓͚ͯ͠ɺଞͷਓ͕༨ܭͳϛεΛ͠ͳ͘ ͯࡁΉ
·ͱΊ » ʮͦͷྫ֎ຊʹѲΓ௵͍͍ͯ͠ͷͩΖ͏͔ʁʯ » ͦΕ͕ʮͲ͏͍͏ྫ֎ͳͷ͔ʯΛ͖ͪΜͱߟ͑Α͏ » JavaScriptΛॻ͘ྔ͕૿͖͑ͯͨ » ੲʮແཧΓੜ͖ͯΔJavaScriptʯ͕·Εͨ »
ࠓͦ͏Ͱͳ͍ɺJSͰΞϓϦέʔγϣϯΛߏங͢Δ » ৭ʑͳࡦΛଧͪɺ҆શͳJavaScriptΛॻ͜͏ʂ
Thank you for listening!