1.typeof适合基本类型及function检测,但不适合null,遇到会失效。       //typeof null; ==> "object"    typeof NaN; =>number
2.Class,通过{}.toString拿到,适合内置对象和基元类型,遇到null和undefined失效;     //object.prototype.toString.apply()
3.instanceof适合自定义对象,也可以用来检测原生对象,在不同iframe和widow间检测时失效

4.constructor

5.duck type

相关文章:

  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2022-01-04
  • 2021-11-20
  • 2021-12-25
  • 2021-12-25
猜你喜欢
  • 2022-12-23
  • 2021-04-12
  • 2021-05-12
  • 2021-05-19
  • 2021-09-17
  • 2021-12-06
相关资源
相似解决方案