129
59

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 5 years have passed since last update.

TypeScriptのObject型とobject型は同じ……と思うじゃん?

Last updated at Posted at 2019-09-05

TypeScriptにはObject型とobject型があるが、それぞれ違う型である。Object型はプリミティブ型のboolean, number, string, symbolも含むのに対し、object型はプリミティブ型を含まない。{}型はObject型と同じだ。

TypeScriptのObject型とobject型の違い

「AがObjectのサブタイプである」というのは「AがObject.prototypeと同じ構造のプロパティとメソッドを持つ」ということなので、そう考えるとBooleanNumberにも.toStringなどが生えており、それらがObject型に含まれるのは不思議なことではない。

Object.prototype - JavaScript | MDN

129
59
1

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
129
59

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?