为了账号安全,请及时绑定邮箱和手机立即绑定

如何删除map()中的重复项

如何删除map()中的重复项

慕丝7291255 2021-12-12 15:32:54
如何删除[].map(). a.href可能包含相同的href链接,我怎样才能阻止这种重复出现的数据?示例:www.example.com | www.example.comconst hrefs = await page.evaluate(() => {    const anchors = document.querySelectorAll('a');    return [].map.call(anchors, a => a.href);});
查看完整描述

1 回答

?
慕码人2483693

TA贡献1860条经验 获得超9个赞

Set hrefs = new Set([].map.call(anchors, a => a.href));

return [...hrefs];


查看完整回答
反对 回复 2021-12-12
  • 1 回答
  • 0 关注
  • 195 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号