var arr2=["a","b",33,["cc","dd"],[['eee',22],["fff",555],["zz",88]],["dff"]]; function exist(arr,exi){ for (var key = 0; key < arr.length; key++) { if(Array.isArray(arr[key])){ exist(arr[key],exi); continue; } console.log(arr[key],exi); if(arr[key]==exi){ console.log("-------------"); return true; } } } console.log(exist(arr2,22));
console.log("-------------");都有输出;
可是却不返回true是为什么?
相关分类