loading...

re: Do's and Don'ts for Javascript Newbies VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I'm a near-intermediate JS developer and was surprised to learn that access by element id is the fastest way. Thanks for posting this! 😄
 

DOM elements are also global when accessed by ID. e.g. window['my_element_id'] or my_element_id #oldschoolweb

 

For sure a bad idea. Just a little anecdote.

Here's some more web anecdotes

Because it's seems not standard :/ but you can easely recreate this idea:

document.querySelectorAll("[id]").forEach(el => window[el.id] = el);

Code of Conduct Report abuse