猿问

javascript递归查找数组元素为什么没有返回true?

         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是为什么?

懒人3899010
浏览 2283回答 2
2回答
随时随地看视频慕课网APP
我要回答