• 2023-04-07模拟循环批量请求后台接口
    使用async,await处理异步请求。用Promise,setTimeout函数模拟后台接口<!DOCTYPEhtml><html><scripttype="text/javascript">vararr=[];varbatchSize=10;for(i=0;i<30;i++){arr.push(i);}functionb(startIdx,endIdx){ returnnewPromise((res
  • 2023-02-05数组中找到与目标值最接近的数字
    //二分法O(logn)constfindNearestTarget=(nums=[1,2,6,9,10],target=3)=>{letstartIdx=0,endIdx=nums.length-1;while(star
  • 2023-02-03千分位分隔符
    constthousandth=(num=123456789,fixed=0)=>{conststrNum=num.toFixed(fixed)const[startStr,endStr]=strNum.split('.')letendIdx=s