DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in

εŽ»ι‡

方法 1

const arr = [1,1,2,3,4,4,5]
const uniqueArr = [...new Set(arr)];
console.log(uniqueArr); //[ 1, 2, 3, 4, 5 ]
Enter fullscreen mode Exit fullscreen mode

方法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 ]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.