类数组举例
let arrayLike = {'0': 'JACK', '1': 'LINDA', length: 2 }
类数组判断
有键值对length 且 length 大于 0 小于 JS限制的最大值 (Math.pow(2, 53) - 1)
const MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
let isArrayLike = (collection) => {
let length = collection != null && collection.length;
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};