Cosen95 / fe_interview

字节、阿里、美团、滴滴、腾讯等大厂高级前端面试题整理
238 stars 25 forks source link

判断数组的方法,并对比它们的优劣 #53

Open Cosen95 opened 4 years ago

lovefishs commented 4 years ago
const foo = []

Array.isArray(foo) // 1
foo.constructor === Array // 2
foo instanceof Array // 3
Object.prototype.toString.call(foo) === '[object Array]' // 4