Skip to content

Commit 6ef9ec1

Browse files
committed
array
1 parent 08b62dc commit 6ef9ec1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Note/JavaScript/01-Array.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,12 @@ it.only('arry concat', () => {
320320
});
321321
```
322322

323-
## 其他
323+
### 数组去重
324324

325-
#### 1.去除数组中重复的元素
325+
#### 1.ES6的Set去重(最简单)
326326

327327
```js
328-
let uniqueArray = [...new Set([1, 2, 5, 5, 5, "luya", "luya", 'haha', false, false, true, true])];
328+
const arr = [1, 2, 5, 5, 5, "luya", "luya", 'haha', false, false, true, true];
329+
let uniqueArray = [...new Set(arr)];
329330
// [1, 2, 5, "luya", "haha", false, true]
330331
```

0 commit comments

Comments
 (0)