猿问

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

如何删除[].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);

});


慕丝7291255
浏览 196回答 1
1回答

慕码人2483693

Set hrefs = new Set([].map.call(anchors, a => a.href));return [...hrefs];
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答