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 Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
290
React本体のコードリーディング
high_g_engineer
1
150
仕様駆動開発の消費期限
watany
20
8.6k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
200
型も通る、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
570
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
190
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
プロポーザルを書いてもらう
pvcresin
0
550
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
240
VibeCodingからAgenticWorkflowへ
starfish719
0
620
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.7k
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
800
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Thoughts on Productivity
jonyablonski
76
5.3k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
250
Fireside Chat
paigeccino
42
4k
Into the Great Unknown - MozCon
thekraken
41
2.7k
We Have a Design System, Now What?
morganepeng
55
8.3k
A Tale of Four Properties
chriscoyier
163
24k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
420
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