使用typeof来检测数据类型

可以使用typeof来检测数据类型:
“undefined”–>这个变量是未定义的(为初始化的变量和未声明的变量的typeof操作都返回undefined)
”boolean“–>这个值是布尔值
”string“ -->这个值是字符串
”number“–>这个值是数字
”object“–>这个值为null或者obejct
”function“–>这个值是函数

Object.prototype.toString.call()

借用一个网络图片说明:js检测数据类型

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-05-10
  • 2021-04-12
  • 2021-05-12
  • 2021-09-17
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2021-12-25
  • 2021-11-30
  • 2022-12-23
  • 2021-12-25
  • 2021-07-30
  • 2022-12-23
相关资源
相似解决方案