Closed laomagege closed 8 years ago
@laomagege I forget check the type of the parameter obj
, so if it's not a Object an error will be throw. I think I can fix this bug by sample change the code like this :
util.isArrayLike = function(obj) {
if(typeof obj !== 'object' || !obj){
return false;
}
var length = obj.length;
return typeof length === 'number'
&& length % 1 === 0 && length >= 0 && length <= MAX_ARRAY_INDEX;
};
Yes, sounds good.
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; util.isArrayLike = function(obj) { var length = obj ? obj['length'] //this line of code will have problem.
var length = obj ? obj['length'] : -1; //could change as this to fix this issue, (null, NaN, undefined length will be -1)