Created
July 25, 2020 16:12
-
-
Save iceener/b610821ad15a536d67b0897691365e9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Take a pics. | |
const findImages = (el, withDuplicates = false) => { | |
const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src')); | |
return withDuplicates ? images : [...new Set(images)]; | |
}; | |
// Examples | |
findImages(document); // ['image1.jpg', 'image2.png'] | |
findImages(document, true); // ['image1.jpg', 'image1.png'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment