方法 1
const arr = [1,1,2,3,4,4,5]
const uniqueArr = [...new Set(arr)];
console.log(uniqueArr); //[ 1, 2, 3, 4, 5 ]
方法2
import _ from 'lodash';
const arr = [1,1,2,3,4,4,5];
const uniqueArr = _.uniq(arr);
console.log(uniqueArr); //[ 1, 2, 3, 4, 5 ]
Top comments (0)