检查数组的方法

instanceof

arr instanceof Array

isPrototypeOf

Array.prototype.isPrototypeOf(arr);

Object.prototype.toString.call();

Object.prototype.toString.call(arr)

constructor;

arr.constructor === Array

Array.isArray

Array.isArray(arr)

duck type 数组的length属性不可枚举,检查length属性是否可枚举

arr.propertyIsEnumerable("length")===false

你可能感兴趣的:(js,数组,js)