首页
技术
登录
6mi
u
盘
搜
搜 索
技术
去除数组中的重复元素
去除数组中的重复元素
技术
2022-07-11
108
function
dedupe
(
array
)
{
return
Array
.
from
(
new
Set
(
array
)
)
;
//这里的 Array.from()方法是将两类对象转为真正的数组:类似数组的对象和可遍历的对象(包括es6新增的数据结构Set和Map)
}
dedupe
(
[
1
,
1
,
1
,
2
,
3
]
)
//[1,2,3]
参考博客地址https://www.cnblogs.com/shj-com/p/7458510.html
转载请注明原文地址:https://ipadbbs.8miu.com/read-15960.html
最新回复
(
0
)