Daniel Brooks
Daniel Brooks

Reputation: 1087

How to remove duplicates in map()

How to remove duplicates in [].map() . a.href may contain the same href link, how can I stop this reoccuring data? EXAMPLE: www.example.com | www.example.com

const hrefs = await page.evaluate(() => {
    const anchors = document.querySelectorAll('a');
    return [].map.call(anchors, a => a.href);
});

Upvotes: 1

Views: 135

Answers (1)

Andy Gaskell
Andy Gaskell

Reputation: 31761

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

Upvotes: 3

Related Questions