当前位置:网站首页>Judge the data type of JS

Judge the data type of JS

2022-06-21 09:14:00 Tie Hanhan plus

Use Object.prototype.toString.call() To determine the array 、 object 、 character string 、 Numeric and Boolean types

Object.prototype.toString.call(1)
// "[object Number]"

Object.prototype.toString.call('string')
// "[object String]"

Object.prototype.toString.call(false)
// "[object Boolean]"

Object.prototype.toString.call({
    })
// "[object Object]"

Object.prototype.toString.call([])
// "[object Array]"
原网站

版权声明
本文为[Tie Hanhan plus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221446081986.html