プリミティブ型

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真偽値

型を取り違えると、実行は通るのに答えだけがおかしくなります。

1 / 4

このスライドが付いているレッスンを開く