getRepeat这个方法是哪里不对呢,怎么结果与预期不符合
// 获得去重之后的数组 Array.prototype.noRepeat = function () { return [...new Set(this)]; } // 被删除的重复条目的新数组 Array.prototype.getRepeat = function () { let noRepeat = new Set(this.noRepeat()); return this.filter((x) => { !noRepeat.has(x) }) } let arr1 = [1,2,3,4,5,4,3,2]; let arr2 = ['a','b','c','d','e','d','c']; let arr1_0 = arr1.noRepeat() let arr1_1 = arr1.getRepeat() let arr2_0 = arr2.noRepeat() let arr2_1 = arr2.getRepeat() //getRepeat这个方法是哪里不对呢,怎么结果与预期不符合?
getRepeat这个方法是哪里不对呢,怎么结果与预期不符合?🤔#笔试题目##前端工程师#