Wait, what happens if you set an id to a value already in use? Does id="undefined" do very terrible things?
ID'd elements go directly into the global namespace? I never knew this! I feel both enlightened and a bit alarmed.
Did not know this. 🤯
I discovered this totaly by accident while toying with with scripts loading (basic idea was to prevent scripts injected via js from loading twice by assigning an id to the script and checking for its existence instead of relying on external state) and YES, it's awesome and also YES, it's terrible 🤣
Say what??
Ah yes, one of my javascript guilty pleasures...
Wait... I've been writing JS for as long as it's existed and I never knew this tip. I've always used document.getElementById() to access DOM elements with IDs. I'm flabbergasted. Thanks for sharing!