js判断类型的方式有哪些

1、typeof---typeof true

2、instanceof----[1,2] instanceof Array

3、constructor-----[1, 2].constructor === Array

4、Object.prototype.toString.call------Object.prototype.toString.call([1, 2])

javascript
58 views
Comments
登录后评论
Sign In
·

养成写 typescript 的习惯,就很少需要用到类型判断了 stuck_out_tongue_closed_eyes