dice
dice
```javascript // 实现 Promise.retry,成功后 resolve 结果,失败后重试,尝试超过一定次数才真正的 reject Promise.retry = function(fn, num){ return new Promise(async function(resolve, reject){ while(num>0){ try{ const res = await fn(); console.log('res: ', res); resolve(res) num = 0...
```javascript /** * 字符串 * @param str * @param target * @param start * @returns {number|*} */ function strIndexOf(str, target, start = 0){ if (start > str.length) { return -1;...
```javascript // 求多个数组之间的交集 function intersection(arr1, arr2) { let s1 = new Set([...arr1]); let s2 = new Set([...arr2]); let result = [] for (let item of s1.values()) { if (s2.has(item)) {...