1.isArray(ES5語法 簡單明了)
Array.isArray()
2.instanceof()
typeof操作符對于一些常用的類型可以判斷嗤练,比如Function于微、String卒暂、Number环鲤、Undefined等,但是要是檢測Array的對象就不起作用了俏蛮。 利用typeof除了array和null判斷為object外,其他的都可以正常判斷
alert(arr instanceof Array)
instanceof(arr.prototype===Array)
3.對象的constructor屬性
alert(arr.constructor === Array)
4.Object.prototype.toString
Object.prototype.toString.call(o) === '[object Array]'
根據(jù)下面的圖看一下原型和構(gòu)造函數(shù)的關(guān)系
圖片.png