JS怎么判断数据类型
2021-12-17 本文已影响0人
i_木木木木木
- 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