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
if文のはなし
Search
tky
March 22, 2019
Programming
610
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
if文のはなし
tky
March 22, 2019
Other Decks in Programming
See All in Programming
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
140
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
170
今さら聞けない .NET CLI
htkym
0
100
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
270
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
3k
act1-costs.pdf
sumedhbala
0
250
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
6
9.6k
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
420
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
540
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
160
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
640
How to Talk to Developers About Accessibility
jct
2
430
Speed Design
sergeychernyshev
33
1.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
RailsConf 2023
tenderlove
30
1.5k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
GitHub's CSS Performance
jonrohan
1033
470k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.7k
Transcript
if文のはなし @ticktakclock
自己紹介 • 竹中貴哉 @ticktakclock • React, Cordova • javascript 始めて
6 ヶ月経ちました • 本業は Android
if ...
const str = 'we are javascripters'; console.log(`length: ${str.length}`); if (str.length
> 0) { // true console.log('ok'); } // > length: 20 // > ok
const str = 'we are javascripters'; if (str.startsWith('we')) { //
true console.log('ok'); } // > ok
if文はtrue/falseで判定するんだ!
const str = 'we are javascripters'; console.log(str); if (str) {
console.log('ok'); } // > we are javascripters // > ok
const str = 'we are javascripters'; console.log(str); if (str !==
null) { console.log('ok'); } // > we are javascripters // > ok
const str = 'we are javascripters'; console.log(str); if (str) {
console.log('ok'); } // > we are javascripters // > ok
ドキュメント https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/if...else#Syntax
truthy? falsy?
truthy https://developer.mozilla.org/ja/docs/Glossary/truthy
const str = 'we are javascripters'; console.log(str); if (str !==
null) { console.log('ok'); } // > we are javascripters // > ok
const str = 'we are javascripters'; console.log(str); if (str) {
console.log('ok'); } // > we are javascripters // > ok
やってみた console.log(0 ? 'truthy' : 'falsy'); // falsy console.log(1 ?
'truthy' : 'falsy'); // truthy console.log(-1 ? 'truthy' : 'falsy'); // truthy console.log('' ? 'truthy' : 'falsy'); // falsy console.log('test' ? 'truthy' : 'falsy'); // truthy console.log(undefined ? 'truthy' : 'falsy'); // falsy console.log(null ? 'truthy' : 'falsy'); // falsy console.log('undefined' ? 'truthy' : 'falsy'); // truthy console.log(new Date() ? 'truthy' : 'falsy'); // truthy
まとめ if文の条件式は何でも入る
string https://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,% 20June%201997.pdf
おしまい
string https://developer.mozilla.org/ja/docs/Web/JavaScript/Data_structures#Strings
var str = ''; console.log(str[0]); // undefined console.log(str.length); // 0
console.log(str.charCodeAt(0)); // NaN str = '\0'; console.log(str[0]); // ’ ’ console.log(str.length); // 1 console.log(str.charCodeAt(0)); // 0