美文网首页
instanceof运算符

instanceof运算符

作者: coffee1949 | 来源:发表于2019-06-15 20:31 被阅读0次
obj instanceof Object // true

上面代码的含义,是将undefined和null转为对象,结果得到了一个空对象obj。

instanceof运算符用来验证,一个对象是否为指定的构造函数的实例。obj instanceof Object返回true,就表示obj对象是Object的实例。

相关文章

网友评论

      本文标题:instanceof运算符

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