Get the name of an object's type

前端 未结 20 2750
忘掉有多难
忘掉有多难 2020-11-21 22:37

Is there a JavaScript equivalent of Java\'s class.getName()?

20条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-21 22:59

    The closest you can get is typeof, but it only returns "object" for any sort of custom type. For those, see Jason Bunting.

    Edit, Jason's deleted his post for some reason, so just use Object's constructor property.

提交回复
热议问题