var flatten = function(input,shallow,strict,startIndex){
var output = [], idx =0;
for(var i = startIndex || 0,length =input && input.length;i < length;i++){
var value = input[i];
if(isArrayLike(value)
&&(_.isArray(value) ||_.isArguments(value))){
if(!shallow) value = flatten(value,shallow,strict);//这里的value递归不是很懂,具体细节是怎样的?麻烦大神讲解一下
var j = 0, len = value.length;
output.length += len;
while(j<len){
output[idx++] = value[j++];
}
}else if(!strict){
output[idx++] = value;
}
}
return output;
};
HUWWW
相关分类