alan

Results 12 comments of alan

var a = [1,2,3] var b = JSON.parse(JSON.stringify(a)) 完事

数组去重或者判断有没有重复元素用new Set()就ok了.

![image](https://user-images.githubusercontent.com/22437481/86076809-54a66e00-babd-11ea-9e30-c01ac7daf00a.png)

> ```js > var arr = [1,[2,3,[4,5]],8] > function flatten(arr) { > return arr.toString().split(",") > } > flatten(arr) > ["1", "2", "3", "4", "5", "8"] > ``` > > 这样呢?...

'红蓝蓝黄红黄蓝红红黄红'.split('').sort((a,b) => {if(a=='黄' || b=='蓝'){return -1}}).join('')

![image](https://user-images.githubusercontent.com/22437481/86090147-271ced00-badc-11ea-8678-df2ae216d05c.png)

![image](https://user-images.githubusercontent.com/22437481/86219338-9fef7800-bbb4-11ea-92c2-df8acc037bec.png)

> > > undefined 10 20 > > > 代码执行过程: > > > `var a; // undefined` > > > `a = 10; ` > > > `(function () {`...

![image](https://user-images.githubusercontent.com/22437481/86345024-92f28780-bc8d-11ea-9593-a92b65b3b94d.png)