Created
June 3, 2025 15:59
-
-
Save andresgallo/aad0494f3e28bd18ad2b22a5d49a0ad2 to your computer and use it in GitHub Desktop.
dupIds
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
| const ids = Array.from(document.querySelectorAll('[id]')) | |
| .map(v => v.id) | |
| .reduce((acc, v) => { | |
| acc[v] = (acc[v] || 0) + 1; | |
| return acc | |
| }, {}); | |
| console.log(ids); | |
| // To get a list of duplicate IDs: | |
| const duplicateIds = Object.entries(ids) | |
| .filter(([key, value]) => value > 1) | |
| .map(([key, value]) => key); | |
| console.log(duplicateIds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment