0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【TypeScript】 Javascriptのデータ型について学習したことをまとめる

0
Last updated at Posted at 2023-02-23

🚨🚨🚨🚨個人的なアウトプット用記事なので、情報収集の人は閲覧注意です🙇
🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨

プリミティブ型

真偽値(boolean) trueとかfalseを扱える


const foo: boolean = trueまたはfalse; OK!

const foo: boolean = 0;booleanは真偽値しか扱えないのでエラーになる。

文字列(string) ”a”とか文字


const foo: string = "スノボー"; OK!

const foo: string = true;stringは文字列しか扱えないのでエラーになる。

・数値(number) 1や0など数字


const foo: number = 1; OK!

const foo: number = trueとか"スキー";numberは数値しか扱えないのでエラーになる。

null 現在利用できない状態の型


const foo: null = null; OK!

const foo: null = "null";null型にはnull以外入れてはいけないのでエラーになる。何も入れてもダメ

undefind 初期化されていない状態の型

const foo: undefind = undefind; OK!

const foo: undefind = "undefind"nullと同じだが

オブジェクト型

プリミティブ型以外
配列、関数とか

Array
Tuple
Any
Unknown
Void
Never

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?