プリミティブ型
TypeScript入門 / 全 4 枚
string / number / boolean の3つ
TypeScript でいちばんよく使う型は string、number、boolean の3つです。プロフィールのデータは、たいていこの3つで書けます。
const name: string = "ゆめさく";
: string文字列const workCount: number = 3;
: number数値const isPublished: boolean = true;
: boolean真偽値const name: string = "ゆめさく";
文字列
const workCount: number = 3;
数値
const isPublished: boolean = true;
真偽値
型を取り違えると、実行は通るのに答えだけがおかしくなります。
1 / 4
← → キーでも送れます