51CTO博客已为您找到关于arr.findIndex的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及arr.findIndex问答内容。更多arr.findIndex相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
returna.filter(x=>s.has(fn(x))); }; intersectionBy([2.1,1.2], [2.3,3.4],Math.floor);// [2.1] 20. `intersectionWith`:先比较后返回交集constintersectionWith =(a, b, comp) =>a.filter(x=>b.findIndex(y=>comp(x, y)) !==-1); intersectionWith([1,1.2,1.5,3,0], [1.9,3,0,3....
I would like to see something similar so I can use a predicate function to insert something after (or before), like findIndex but to avoid another line: insertAfter(arr, newItem, { key: 'somevalue' }) Instead of const index = findIndex(arr, { key: 'somevlaue' }); arr.splice(index...
return this.reduce((total, current, index) => { return fn.call(context, current, index, this) ? [...total, current] : [...total] }, []) } 5.遍历数组的一些方法 const mySome = function (fn, context) { let arr = Array.prototype.slice.call(this); // The empty array returns f...