bobi

Results 6 comments of bobi

```js let promises: any[] = [] urls.forEach((url: any) => { promises.push(fetch(url)) }) Promise.race(promises).then((res) => { return res })

```js // 在js中实现并发,可以使用promise.all的方法也可以用async await方法来实现 export const multiFetch = () => { let api1 = new Promise((resolve: any, reject: any) => { setTimeout(() => { resolve('api1') }, 2000) }) let api2...

用settimeout去模拟请求 ```js export const fastestApi = () => { let api1 = new Promise((resolve: any, reject: any) => { setTimeout(() => { resolve('api1') }, 1000) }) let api2 = new...

要最后init ```html Document 11111 22222222 333333333 展示 let res=document.getElementById("div") const Router=function(){ this.route={} this.curUrl='' this.addRoute=(path,cb)=>{ this.route[path]=cb||function(){} console.log(this.route); } this.refresh=()=>{ this.curUrl=location.hash.split('#')[1]||'/' console.log(this.route); this.route[this.curUrl]() } let res=document.getElementById('div') this.init=()=>{ console.log(123); window.addEventListener("load",this.refresh(),false) window.addEventListener("hashchange",this.refresh(),false) } }...

array.fill*() > 1. 数组的length属性 > > ```js > var array = [1, 2, 3]; > array.length = 0; > ``` > > 2.splice方法 > > ```js > var array =...