Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
数値の文字列をパースしよう
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
circled9
June 28, 2024
Programming
0
260
数値の文字列をパースしよう
circled9
June 28, 2024
Tweet
Share
More Decks by circled9
See All by circled9
キースイッチ入門
circled9
0
95
CloudflareのAI関連の機能さわってみた
circled9
0
780
0.0.0.0 day
circled9
0
120
小数の丸め誤差の話
circled9
0
150
🔥 Hono v4 やってみた
circled9
1
210
JetBrains AI Assistant を試してみた
circled9
1
560
Fresh
circled9
0
260
React Hooks 勉強会 vol.3
circled9
2
460
JSON.stringify()
circled9
2
500
Other Decks in Programming
See All in Programming
SourceGeneratorのススメ
htkym
0
170
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1k
CSC307 Lecture 04
javiergs
PRO
0
650
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
130
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
AI時代の認知負荷との向き合い方
optfit
0
110
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
430
dchart: charts from deck markup
ajstarks
3
980
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
360
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
2.4k
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
500
Patterns of Patterns
denyspoltorak
0
1.3k
Featured
See All Featured
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
76
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
120
The Limits of Empathy - UXLibs8
cassininazir
1
210
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
51
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
130
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
How to Ace a Technical Interview
jacobian
281
24k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Transcript
ͷจࣈྻΛύʔε͠Α͏ Niigata 5min Tech #9 @circled9 1
ࣗݾհ @circled9 দҪɹਖ਼ࢤ / Matsui Masashi גࣜձࣾϞχΫϧ TypeScriptͰ৭ʑܭࢉ͢ΔࣄΛ ͯ͠·͢ 2
ͷจࣈྻͷύʔε • JavaScriptͰͷจࣈྻͷύʔε͠·͢ΑͶʁ • parseInt, parseFloat, NumberͷͲΕ͍͍͔͑Έ·ͤΜ ͔ʁ • ͱ͍͏Θ͚Ͱ৭ʑύʔεͯ͠Έ·ͨ͠
3
4
"123" 5
ී௨ͷͷ߹ > parseInt("123") <- 123 > parseFloat("123") <- 123 >
Number("123") <- 123 6
"123,456" 7
ܻ̏۠Γͷͷ߹ > parseInt("123,456") <- 123 > parseFloat("123,456") <- 123 >
Number("123,456") <- NaN 8
"123_456" 9
Numeric Separator • ES2021ͷه๏ • ͷ۠Γจࣈͱͯ͠ΞϯμʔείΞ͕͑Δ > 123_456_789 <- 123456789
10
ΞϯμʔείΞ۠Γͷͷ߹ > parseInt("123_456") <- 123 > parseFloat("123_456") <- 123 >
Number("123_456") <- NaN 11
ͷ·ͱΊ • parseIntͱparseFloatҎ֎ͷจࣈ͕ग़ͯ͘Δ·Ͱύʔε͢ Δ • Numberมͳจࣈ͕͋ΔͱNaNΛฦ͢ 12
খ 13
"1.23" 14
ී௨ͷখͷ߹ > parseInt("1.23") <- 1 > parseFloat("1.23") <- 1.23 >
Number("1.23") <- 1.23 15
".123" 16
খͷলུܗͷ߹ > parseInt(".123") <- NaN > parseFloat(".123") <- 0.123 >
Number(".123") <- 0.123 17
"192.168.1.1" 18
খͰͳ͍Կ͔ͩͬͨ߹ > parseInt("192.168.1.1") <- 192 > parseFloat("192.168.1.1") <- 192.168 >
Number("192.168.1.1") <- NaN 19
খͷ·ͱΊ • parseIntҎ֎ͷจࣈ͕ग़ͯ͘Δ·Ͱύʔε͢Δ • parseFloatখͱͯ͠ύʔεͰ͖Δͱ͜Ζ·Ͱύʔε͢Δ • Numberখͱ͓͔͍ͯ͠͠߹NaNΛฦ͢ 20
ͦͷଞͷ 21
"1.234E-5" 22
ࢦදهͷ߹ > parseInt("1.234E-5") <- 1 > parseFloat("1.234E-5") <- 0.00001234 >
Number("1.234E-5") <- 0.00001234 23
"Infinity" 24
In fi nityͷ߹ > parseInt("-Infinity") <- NaN > parseFloat("-Infinity") <-
-Infinity > Number("-Infinity") <- -Infinity 25
" 123 " 26
લޙʹۭന͕͋Δ߹ > parseInt(" 123 ") <- 123 > parseFloat(" 123
") <- 123 > Number(" 123 ") <- 123 27
" 1 2 3 " 28
్தʹۭന͕͋Δ߹ > parseInt(" 1 2 3 ") <- 1 >
parseFloat(" 1 2 3 ") <- 1 > Number(" 1 2 3 ") <- NaN 29
ͦͷଞͷͷ·ͱΊ • parseFloatNumberࢦදهInfinityʹରԠ͍ͯ͠Δ • Ͳͷؔจࣈྻͷલޙͷۭനແࢹ͢Δ • Ͳͷؔจࣈྻͷ్தͷۭനύʔεͰ͖ͳ͍จࣈѻ͍ʹͳΔ 30
ۭͷ 31
"" 32
ۭจࣈͷ߹ > parseInt("") <- NaN > parseFloat("") <- NaN >
Number("") <- 0 33
null 34
nullͷ߹ > parseInt(null) <- NaN > parseFloat(null) <- NaN >
Number(null) <- 0 35
undefined 36
unde fi nedͷ߹ > parseInt(undefined) <- NaN > parseFloat(undefined) <-
NaN > Number(undefined) <- NaN 37
ۭͷͷ·ͱΊ • NumberۭനจࣈͱnullΛύʔε͢Δͱ0Λฦ͢ • ҰํɺparseIntͱparseFloatNaNΛฦ͢ • ͲͷؔundefinedΛύʔε͢ΔͱNaNΛฦ͢ 38
·ͱΊ 39
·ͱΊ • parseIntࣈͷ෦ΛͰ͖Δ͚ͩύʔε͢Δ • parseFloatখͬΆ͍෦ΛͰ͖Δ͚ͩύʔε͢Δ • Numberมͳจࣈ͕ೖͬͯΔͱNaNΛฦ͢ • Numberͷۭനจࣈͱnullͷڍಈʹҙ 40
͓·͚ 41
͜ΕΒҰॹ > parseInt === Number.parseInt <- true > parseFloat ===
Number.parseFloat <- true 42
͜ΕҰॹ > +"" === Number("") <- true 43