美文网首页
JS怎么判断数据类型

JS怎么判断数据类型

作者: i_木木木木木 | 来源:发表于2021-12-17 13:43 被阅读0次
  • typeof
typeof("")  //string
typeof([])  //object
typeof({})  //object
  • Array.isArray()
Array.isArray("")  //false
Array.isArray({})  //false
Array.isArray([])  //true
  • constructor
let a="",b=[],c={};
a. constructor === String   //true
b. constructor === Array   //true
c. constructor === Object   //true

相关文章

网友评论

      本文标题:JS怎么判断数据类型

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