Skip to content

Instantly share code, notes, and snippets.

@marcogrcr
Created May 28, 2024 18:25
Show Gist options
  • Save marcogrcr/d027e65f3368058e0a77a001e22f4e96 to your computer and use it in GitHub Desktop.
Save marcogrcr/d027e65f3368058e0a77a001e22f4e96 to your computer and use it in GitHub Desktop.
Print element attributes
((selector) => Array
.from(document.querySelectorAll(selector))
.map(x => Array
.from(Array(x.attributes.length).keys())
.reduce((o, i) => ({ [x.attributes.item(i).name]: x.attributes.item(i).value, ...o }), {})
)
)('meta')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment