let a = [1,3,4,5,6,7]
console.log(Array.isArray(a)) //true
console.log(Array.isArray([]))
let b = [1,4,5]
console.log(b instanceof Array)
//利用构造函数
function isArray(arr) {
return arr.constructor.toString().indexOf("Array") > -1;
}
function isArray(arr) {
return arr.constructor === Array;
}
console.log(isArray(a))
let o = {}
console.log(o.constructor === Object) // true
let m = new Object
console.log(m.constructor === Object) // true
let p = []
console.log(p.constructor === Array) // true
let e = new Array
console.log(e.constructor === Array) // true
let n = new Number(3)
console.log(n.constructor === Number) // true
let str = 3
const arr = new Array(str)
console.log(arr.constructor === Array)
console.log('arr.constructor is ' + arr.constructor)
console.log(arr.constructor.toString())
console.log(typeof function(){})
console