let str = 'asdfesauiodb';
function foo(str){
const len =str.length;
let i = 0;
let j = 0;
let ans = 0;
function fn(){
if(str.substring(i,j).indexOf(str[j])<0){
j++
} else {
i++
}
ans = Math.max(ans,j);
if(i<=j&&j<len){
return fn();
} else {
console.log("最长字符串为:"+str.slice(i,ans));
}
}
fn();
}
foo(str)