HCC0007

Results 6 comments of HCC0007

弱弱的发一个, 思路: fn 属于 Promise while 需要 await 阻塞 递归 可以直接回调 异步 ```javascript Promise.retry = function (fn, count) { return new Promise((resolve, reject) => { console.log(count) const pro = fn();...

```javascript function getIndex(arr) { const min = Math.min(...(arr.filter(i => i > 0))); const index = arr.indexOf(min); return index + ',' + min; } const arr = [10,21,0,-7,35,7,9,23,18]; console.log(getIndex(arr)); ```

思路: 砍左中右三个部分,然后分别处理。 ```javascript const arr = [1, 2, 12, 32, 43] const after = arr.splice(-1, -2,33, 4); console.log('答案 ---', arr, after); const arr2 = [1, 2, 12, 32, 43]; function...

> > ```js > > Array.prototype.mySplice = function(start, deleteCount, ...items) { > > const preLen = this.length + items.length > > const rightArr = items.concat(this.slice(start + deleteCount)) > > let...

```javascript Object.prototype.map = function(fn) { const deepclone = JSON.parse(JSON.stringify(this)); return Object.keys(deepclone).reduce((result, key, index) => { result[key] = fn(deepclone[key], key, index); return result; }, {}) } const obj = { a:...