/** * @param{string} s * @return{number} */varlengthOfLongestSubstring=function(s) {let temp = [];let result =0;for (let i =0; i <s.length; i ++) {constindex=temp.indexOf(s[i]);temp.push(s[i]); index !==-1&& (temp.splice(0, index +1)); result =Math.max(result,temp.length) }return result;};