数组 - 混淆的地方

mac2022-06-30  21

判断是否为数组

1 var is_array = function(value) { 2 return value && typeof value === 'object' && typeof value.length === 'number' && typeof value.splice === 'function' && !(value.propertyIsEnumerable('length')); 3 }; 4 5 //使用方法 6 var arrayValue = []; 7 console.log(is_array(arrayValue));

 

转载于:https://www.cnblogs.com/qzsonline/archive/2012/07/15/2592437.html

最新回复(0)