美文网首页
js求对象类型三种方式

js求对象类型三种方式

作者: 晓露_0d5c | 来源:发表于2021-04-16 11:16 被阅读0次

typeof

对象类型

var a ="5435"
typeof a  // string
image.png

instance of

var a ="4324"
a instanceof String // false
a instanceof Object // false
a.constructor.name // "String"

var b=new String("45435")
b instanceof String //true
b instanceof Object // true
b.constructor.name // "String"

object instanceof constructor
对象是否是构造函数的实例


image.png

constructor

var a ="fsdf"
a.contructor.name // "String"
image.png

#

相关文章

网友评论

      本文标题:js求对象类型三种方式

      本文链接:https://www.haomeiwen.com/subject/irzslltx.html