来源:牛客网
Array.prototype.noRepeat = () => { return [...new Set(this)]; } //这里有个奇怪的问题 let arr = [1,2,3,4,5,4,3] let a1 = arr.noRepeat() // a1 [1, 2, 3, 4, 5] let arr2 = ['a','b','c','d','b','a'] let b = arr2.noRepeat() // b [1, 2, 3, 4, 5],这里为什么会报错呢??? | |
全部评论
(1) 回帖