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
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
200
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
420
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
250
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.7k
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
500
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
160
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
2
730
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
140
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
370
MySQLとPostgreSQLって何が違うの?
akagami
PRO
0
160
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Google's AI Overviews - The New Search
badams
0
1.6k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
490
Skip the Path - Find Your Career Trail
mkilby
1
220
How to train your dragon (web standard)
notwaldorf
97
6.8k
KATA
mclloyd
PRO
35
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Invisible Side of Design
smashingmag
301
52k
Mind Mapping
helmedeiros
PRO
1
340
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
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