如何删除 [].map()
中的重复项。 a.href
可能包含相同的 href
链接,我怎样才能停止这种重复出现的数据?示例:www.example.com | www.example.com
const hrefs = await page.evaluate(() => {
const anchors = document.querySelectorAll('a');
return [].map.call(anchors, a => a.href);
});
最佳答案
Set hrefs = new Set([].map.call(anchors, a => a.href));
return [...hrefs];
关于javascript - 如何删除 map() 中的重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58652967/